Use an enum for error codes
This commit is contained in:
parent
4be31d0f08
commit
cd6820e810
1 changed files with 18 additions and 14 deletions
22
src/types.ts
22
src/types.ts
|
|
@ -82,12 +82,20 @@ export const JSONRPCResponseSchema = z
|
|||
})
|
||||
.strict();
|
||||
|
||||
// Standard JSON-RPC error codes
|
||||
export const PARSE_ERROR = -32700;
|
||||
export const INVALID_REQUEST = -32600;
|
||||
export const METHOD_NOT_FOUND = -32601;
|
||||
export const INVALID_PARAMS = -32602;
|
||||
export const INTERNAL_ERROR = -32603;
|
||||
/**
|
||||
* An incomplete set of error codes that may appear in JSON-RPC responses.
|
||||
*/
|
||||
export enum ErrorCode {
|
||||
// SDK error codes
|
||||
ConnectionClosed = -1,
|
||||
|
||||
// Standard JSON-RPC error codes
|
||||
ParseError = -32700,
|
||||
InvalidRequest = -32600,
|
||||
MethodNotFound = -32601,
|
||||
InvalidParams = -32602,
|
||||
InternalError = -32603,
|
||||
}
|
||||
|
||||
/**
|
||||
* A response to a request that indicates an error occurred.
|
||||
|
|
@ -802,8 +810,6 @@ export const ServerResultSchema = z.union([
|
|||
ListToolsResultSchema,
|
||||
]);
|
||||
|
||||
export const CONNECTION_CLOSED_ERROR = -1;
|
||||
|
||||
export class McpError extends Error {
|
||||
constructor(
|
||||
public readonly code: number,
|
||||
|
|
|
|||
Loading…
Reference in a new issue