NotionClientErrorBase class. Each error has a unique code property for easy identification.
APIResponseError
Thrown when the Notion API responds with an error. This is the most common error type you’ll encounter.Properties
code: APIErrorCode- The specific error code from the API (see Error Codes)status: number- HTTP status codemessage: string- Human-readable error messageheaders: Response.headers- HTTP response headersbody: string- Raw response bodyadditional_data?: Record<string, string | string[]>- Additional error context from the APIrequest_id?: string- Notion request ID for support inquiries
Type Guard
Example
RequestTimeoutError
Thrown when a request to the Notion API exceeds the configured timeout (default: 60 seconds).Properties
code: ClientErrorCode.RequestTimeout- Always set to"notionhq_client_request_timeout"message: string- Error message (default: “Request to Notion API has timed out”)
Type Guard
Example
UnknownHTTPResponseError
Thrown when the API responds with an unexpected format or unknown error code. This typically indicates a response that doesn’t match the expected error structure.Properties
code: ClientErrorCode.ResponseError- Always set to"notionhq_client_response_error"status: number- HTTP status codemessage: string- Error message (default includes status code)headers: Response.headers- HTTP response headersbody: string- Raw response body
Type Guard
Example
InvalidPathParameterError
Thrown when a path parameter contains invalid characters that could alter the intended API endpoint, such as path traversal sequences (..).
Properties
code: ClientErrorCode.InvalidPathParameter- Always set to"notionhq_client_invalid_path_parameter"message: string- Error message describing the invalid parameter