-
Notifications
You must be signed in to change notification settings - Fork 2
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
Auto-Trace Version 2 has arrived! #8
Conversation
@@ -10,6 +10,10 @@ export function addGlobalMiddleware(middlewareFn) { | |||
globalMiddlewares.push(middlewareFn) | |||
} | |||
|
|||
export function removeAllGlobalMiddlewares(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mainly so that tests can reset the middleware; figured others may want to reset the middleware as well.
const err = rawError || new Error(); | ||
const middlewareErr = executeMiddleware(err, extraMiddlewares); | ||
return wrapObjectWithError(middlewareErr); | ||
export function syncStacktrace(callback = ()=>{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I like this change -- we can still call the middleware properly without doing this by doing something like this:
const stacktraceErr = new Error();
const syncMiddlewareErrFunctions = executeAsyncMiddleware(stacktraceErr);
executeSyncMiddleware(syncMiddlewareErrFunctions, stacktraceErr)
return stacktraceErr;
So in the case of synchronous apis, the middleware is called with the same Error for both asyncErr and syncErr, but in the case of asynchronous apis, the middleware is given two separate errors. This is at least what I remember deciding on when talking with you and Bret.
What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't remembered that decision, sounds like a good plan though, this simplifies syncStacktrace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ready! Nice work on this!
* @param {Object} extraContext String or Object to stringify and append to the error message | ||
* @return {Error} Error with extraContext | ||
*/ | ||
export function appendExtraContext(error, extraContext){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this!
🚶 |
New Auto-Trace API - Packed full of tests and documentation