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

Added context and changed parameter structure to object #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

supachris28
Copy link
Contributor

@supachris28 supachris28 commented Feb 14, 2020

I've added a context object (as any) to allow an error to be logged with more context information about what was going on. I've added this as a further parameter, but I've also changes it so the first parameter can either be a message or a config object to save you doing the following:

throw new ErrorCustom('it failed', 400, 1234565, null, null, { productId: '978123456789', event });

Now you can do:

throw new ErrorCustom({
  message: 'it failed',
  statusCode: 400,
  errorCode: 1234565,
  context: { productId: '978123456789', event },
});

This does have the knock on effect that statusCode and errorCode are optional in the main signature, but they are still validated to exist at runtime, but it deconstructs them from the config object first.

@supachris28
Copy link
Contributor Author

Please read the above comment. This will require some consideration as to whether it is appropriate as is, even as a major version bump.

aashutoshbane
aashutoshbane previously approved these changes Feb 17, 2020
afareed007
afareed007 previously approved these changes Feb 17, 2020
AStevensTaylor
AStevensTaylor previously approved these changes Feb 19, 2020
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

Successfully merging this pull request may close these issues.

5 participants