Skip to content

Commit 62f0832

Browse files
committed
export new error helpers and types
1 parent 240608e commit 62f0832

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/errors.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export enum ClientErrorCode {
2727
}
2828

2929
/**
30-
* Error codes on errors thrown by the [[Client]].
30+
* Error codes on errors thrown by the `Client`.
3131
*/
3232
export type NotionErrorCode = APIErrorCode | ClientErrorCode
3333

@@ -82,6 +82,9 @@ export function isNotionClientErrorWithCode<Code extends NotionErrorCode>(
8282
return isNotionClientError(error) && error.code in codes
8383
}
8484

85+
/**
86+
* Error thrown by the client if a request times out.
87+
*/
8588
export class RequestTimeoutError extends NotionClientErrorBase<ClientErrorCode.RequestTimeout> {
8689
readonly code = ClientErrorCode.RequestTimeout
8790
readonly name = "RequestTimeoutError"
@@ -150,6 +153,7 @@ export function isHTTPResponseError(
150153
UnknownHTTPResponseError | APIResponseError,
151154
typeof error
152155
>
156+
153157
return true
154158
}
155159

src/index.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
export { default as Client } from "./Client"
22
export { LogLevel, Logger } from "./logging"
33
export {
4+
// Error codes
5+
NotionErrorCode,
46
APIErrorCode,
7+
ClientErrorCode,
8+
// Error types
9+
NotionClientError,
510
APIResponseError,
6-
HTTPResponseError,
11+
UnknownHTTPResponseError,
712
RequestTimeoutError,
13+
// Error helpers
14+
isNotionClientError,
15+
isNotionClientErrorWithCode,
816
} from "./errors"

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"resolveJsonModule": true,
3030

3131
// Linter style rules
32-
"noUnusedLocals": true,
32+
"noUnusedLocals": false, // Disabled because we use eslint for this.
3333
"noUnusedParameters": true,
3434
"noImplicitReturns": true,
3535
"noFallthroughCasesInSwitch": true,

0 commit comments

Comments
 (0)