forked from barbajs/barba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): 🔊 add/improve error logs
Closes barbajs#447
- Loading branch information
1 parent
baabea4
commit e67a17b
Showing
12 changed files
with
158 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { BarbaError } from '../../src/modules/Error'; | ||
|
||
const err = new Error('Test error'); | ||
|
||
it('has defaults', () => { | ||
const e = new BarbaError(err); | ||
|
||
expect(e.name).toBe('BarbaError'); | ||
expect(e.label).toBe('Barba error'); | ||
expect(e.error).toBe(err); | ||
}); | ||
|
||
it('has params', () => { | ||
const e = new BarbaError(err, 'Label error', 'Message error'); | ||
|
||
expect(e.name).toBe('BarbaError'); | ||
expect(e.label).toBe('Label error'); | ||
expect(e.message).toBe('Message error'); | ||
expect(e.error).toBe(err); | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/core/__tests__/modules/transitions/transitions.context.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | ||
export class BarbaError extends Error { | ||
/* istanbul ignore next */ | ||
constructor( | ||
public error: Error, | ||
public label = 'Barba error', | ||
...params: any[] | ||
) { | ||
// Pass remaining arguments (including vendor specific ones) to parent constructor | ||
super(...params); | ||
|
||
// Maintains proper stack trace for where our error was thrown (only available on V8) | ||
/* istanbul ignore else */ | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, BarbaError); | ||
} | ||
|
||
this.name = 'BarbaError'; | ||
} | ||
} |
Oops, something went wrong.