Skip to content

Commit bd5833c

Browse files
committed
Throw ErrUnexpected if assert fails
1 parent ac580ea commit bd5833c

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ module.exports = {
1919
name: 'crypto',
2020
message: 'Import from crypto.ts',
2121
},
22+
{
23+
name: 'Error',
24+
message: 'Use `ErrUnexpected`',
25+
},
2226
],
2327
'import/order': [
2428
'error',

src/assert.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { ErrUnexpected } from './errors';
2+
13
export function notNull<T>(input: T | null | undefined): T {
24
/* c8 ignore next 3 */
35
if (input === null || input === undefined) {
4-
throw new Error('Input was undefined');
6+
throw new ErrUnexpected('Input was undefined');
57
}
68
return input;
79
}

src/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line no-restricted-globals
12
export class SqlCursorPaginationError extends Error {
23
constructor(name: string, message: string) {
34
super(message);

0 commit comments

Comments
 (0)