Skip to content

Added context and changed parameter structure to object#15

Open
supachris28 wants to merge 4 commits into
masterfrom
add-context
Open

Added context and changed parameter structure to object#15
supachris28 wants to merge 4 commits into
masterfrom
add-context

Conversation

@supachris28

@supachris28 supachris28 commented Feb 14, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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