-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(errors): Custom RxJS errors now all have a call stack #5686
fix(errors): Custom RxJS errors now all have a call stack #5686
Conversation
@@ -0,0 +1,15 @@ | |||
/** @prettier */ | |||
|
|||
export function createErrorClass<T>(name: string, setup: (this: Error, ...args: any[]) => void): T { |
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 I'm going to add a doc comment about why this exists.
|
||
/** @test {concat} */ | ||
describe('concat operator', () => { | ||
let rxTest: TestScheduler; | ||
|
||
beforeEach(() => { | ||
rxTest = new TestScheduler(assertDeepEquals); | ||
rxTest = new TestScheduler(observableMatcher); |
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.
NOTE: These had to be changed, because a simple deep-equals check fails for expect(new CustomError()).to.deep.equal(new CustomError())
once call stacks are in the mix.
const MySpecialError: any = createErrorClass( | ||
(_super) => | ||
function MySpecialError(this: any, arg1: number, arg2: string) { | ||
_super(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.
tiny nit: would it be cleaner to call _super(this, 'Super special error')
instead?
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.
_super is probably a bad name, I'm just not sure what else to call it. :\
NOTE: Because we have to workaround compilation-to-ES5 inadequacies until call stack locations will show as being inside of the constructor implementation at the top level. This will go away as we move the community to ES2015+ BREAKING CHANGE: Tests that are written with naive expectations against errors may fail now that errors have a proper `stack` property. In some testing frameworks, a deep equality check on two error instances will check the values in `stack`, which could be different. fixes ReactiveX#4250
- Adds tests
3a8e531
to
ac7aa52
Compare
NOTE: Because we have to workaround compilation-to-ES5 inadequacies until call stack locations will show as being inside of the constructor implementation at the top level. This will go away as we are able to move the community to ES2015+
BREAKING CHANGE: Tests that are written with naive expectations against errors may fail now that errors have a proper
stack
property. In some testing frameworks, a deep equality check on two error instances will check the values instack
, which could be different.fixes #4250