Skip to content

Instantly share code, notes, and snippets.

@saml
Created June 8, 2020 14:52
Show Gist options
  • Save saml/fe53cfbf6812cc85a73363e8a9c63ad0 to your computer and use it in GitHub Desktop.
Save saml/fe53cfbf6812cc85a73363e8a9c63ad0 to your computer and use it in GitHub Desktop.
class AuthError extends Error {
constructor(message) {
super(message);
// Error.captureStackTrace(this, AuthError);
}
}
function f(o) {
try {
const [_, token] = o.authorization.split('Bearer ');
return token;
} catch (err) {
throw new AuthError('Authorization header is malformed');
}
}
// I want stacktrace to include
// TypeError: Cannot read property 'authorization' of undefined
f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment