Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Exceptions and Error Codes #1

Open
ChrisTalman opened this issue Feb 6, 2018 · 3 comments
Open

Proposal: Exceptions and Error Codes #1

ChrisTalman opened this issue Feb 6, 2018 · 3 comments

Comments

@ChrisTalman
Copy link

It would be great for the module, when it encounters an error, to throw an Error object containing a documented error code.

This would enable user code to reliably try... catch each module method and handle each error type specifically. Currently, this is not possible, with each method returning null on error, and the error information being displayed separately with console.log.

I'd be happy to implement this myself but I don't currently have the time on my hands. So, I thought it prudent to raise the issue here as a matter of recordkeeping if nothing more.

By the way, thanks to @DiegoZoracKy for providing this module. It's great. 👍

@DiegoZoracKy
Copy link
Owner

Hi @ChrisTalman, I'm sorry for taking so long to give you an answer. I totally missed this. The code of this module is very old (I believe this is the first module I published), and its style is really missing some important parts as you pointed out. You are totally right.

The promise based methods are already properly using reject in case of errors, and are not logging anything. The methods decode and encode should indeed return Error without sending anything out to stdout(console.log). Would you like to send a PR with this changes? Don't worry if you don't have the time. Just let me know.

Thanks 👍

@ChrisTalman
Copy link
Author

Hey @DiegoZoracKy. Thanks for getting back to me. Sadly I don't have the time right now.

@DiegoZoracKy
Copy link
Owner

I'll try to take a look at this on the following weeks. Thanks for opening this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants