tangjinzhou
3 years ago
8 changed files with 67 additions and 29 deletions
@ -0,0 +1,8 @@
|
||||
import UnreachableException from '../unreachableException'; |
||||
|
||||
describe('UnreachableException', () => { |
||||
it('error thrown matches snapshot', () => { |
||||
const exception = new UnreachableException('some value'); |
||||
expect(exception.error.message).toMatchInlineSnapshot(`"unreachable case: \\"some value\\""`); |
||||
}); |
||||
}); |
@ -0,0 +1,7 @@
|
||||
export default class UnreachableException { |
||||
error: Error; |
||||
|
||||
constructor(value: never) { |
||||
this.error = new Error(`unreachable case: ${JSON.stringify(value)}`); |
||||
} |
||||
} |
Loading…
Reference in new issue