@shware/http 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/error/status.cjs.map +1 -1
- package/dist/error/status.mjs.map +1 -1
- package/dist/hono/handler.cjs +56 -9
- package/dist/hono/handler.cjs.map +1 -1
- package/dist/hono/handler.d.cts +8 -1
- package/dist/hono/handler.d.cts.map +1 -1
- package/dist/hono/handler.d.mts +8 -1
- package/dist/hono/handler.d.mts.map +1 -1
- package/dist/hono/handler.mjs +58 -12
- package/dist/hono/handler.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.cjs","names":[],"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was cancelled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":";;AAEA,MAAa,OAAO;CAIlB,IAAI;CAKJ,WAAW;CASX,SAAS;CAQT,kBAAkB;CASlB,mBAAmB;CAWnB,WAAW;CAMX,gBAAgB;CAYhB,mBAAmB;CAMnB,oBAAoB;CAoBpB,qBAAqB;CASrB,SAAS;CAmBT,cAAc;CAMd,eAAe;CAOf,UAAU;CAWV,aAAa;CAKb,WAAW;CAMX,iBAAiB;CAKjB,oBAAoB;AACtB;AAEA,MAAa,mBAAsD;CACjE,IAAI;CACJ,WAAW;CACX,SAAS;CACT,kBAAkB;CAClB,mBAAmB;CACnB,WAAW;CACX,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACpB,qBACE;CACF,SAAS;CACT,cAAc;CACd,eAAe;CACf,UAAU;CACV,aAAa;CACb,WAAW;CACX,iBAAiB;CACjB,oBAAoB;AACtB;AAWA,IAAa,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C1E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,kBAAkB,OAAO;CACpF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,gBAAgB,YAAqB,WAAW,GAAG,mBAAmB,OAAO;CACpF,OAAO,qBAAqB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;CAC5F,OAAO,sBAAsB,YAAqB,WAAW,GAAG,uBAAuB,OAAO;CAC9F,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,cAAc,YAAqB,WAAW,GAAG,gBAAgB,OAAO;CAC/E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,iBAAiB,OAAO;CACnF,OAAO,YAAY,YAAqB,WAAW,GAAG,YAAY,OAAO;CACzE,OAAO,eAAe,YAAqB,WAAW,GAAG,eAAe,OAAO;CAC/E,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,oBAAoB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F"}
|
|
1
|
+
{"version":3,"file":"status.cjs","names":[],"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was canceled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":";;AAEA,MAAa,OAAO;CAIlB,IAAI;CAKJ,WAAW;CASX,SAAS;CAQT,kBAAkB;CASlB,mBAAmB;CAWnB,WAAW;CAMX,gBAAgB;CAYhB,mBAAmB;CAMnB,oBAAoB;CAoBpB,qBAAqB;CASrB,SAAS;CAmBT,cAAc;CAMd,eAAe;CAOf,UAAU;CAWV,aAAa;CAKb,WAAW;CAMX,iBAAiB;CAKjB,oBAAoB;AACtB;AAEA,MAAa,mBAAsD;CACjE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AAW,GAAG,aAAa,OAAO;CAC3E,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,mBAAmB,YAAqB,WAAW,GAAG,oBAAoB,OAAO;CACxF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,kBAAkB,OAAO;CACpF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,gBAAgB,YAAqB,WAAW,GAAG,mBAAmB,OAAO;CACpF,OAAO,qBAAqB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;CAC5F,OAAO,sBAAsB,YAAqB,WAAW,GAAG,uBAAuB,OAAO;CAC9F,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,cAAc,YAAqB,WAAW,GAAG,gBAAgB,OAAO;CAC/E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,iBAAiB,OAAO;CACnF,OAAO,YAAY,YAAqB,WAAW,GAAG,YAAY,OAAO;CACzE,OAAO,eAAe,YAAqB,WAAW,GAAG,eAAe,OAAO;CAC/E,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,oBAAoB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.mjs","names":[],"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was cancelled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":";AAEA,MAAa,OAAO;CAIlB,IAAI;CAKJ,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CAC9C;CAEA,SAAS,SAA6B;EACpC,MAAM,OAAO,KAAK,KAAK,OAAO;EAC9B,OAAO,SAAS,KAAK,MAAM,EAAE,QAAQ,KAAK,MAAM,KAAK,CAAC;CACxD;AACF;AAEA,IAAa,SAAb,MAAoB;CAClB,OAAO;CAEP,OAAO,MAAM,YAAqB,WAAW,GAAG,MAAM,OAAO;CAC7D,OAAO,aAAa,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC3E,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,mBAAmB,YAAqB,WAAW,GAAG,oBAAoB,OAAO;CACxF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,kBAAkB,OAAO;CACpF,OAAO,oBAAoB,YAAqB,WAAW,GAAG,qBAAqB,OAAO;CAC1F,OAAO,gBAAgB,YAAqB,WAAW,GAAG,mBAAmB,OAAO;CACpF,OAAO,qBAAqB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;CAC5F,OAAO,sBAAsB,YAAqB,WAAW,GAAG,uBAAuB,OAAO;CAC9F,OAAO,WAAW,YAAqB,WAAW,GAAG,WAAW,OAAO;CACvE,OAAO,cAAc,YAAqB,WAAW,GAAG,gBAAgB,OAAO;CAC/E,OAAO,iBAAiB,YAAqB,WAAW,GAAG,iBAAiB,OAAO;CACnF,OAAO,YAAY,YAAqB,WAAW,GAAG,YAAY,OAAO;CACzE,OAAO,eAAe,YAAqB,WAAW,GAAG,eAAe,OAAO;CAC/E,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,oBAAoB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F"}
|
|
1
|
+
{"version":3,"file":"status.mjs","names":[],"sources":["../../src/error/status.ts"],"sourcesContent":["import type { Detail, Details } from './detail';\n\nexport const Code = {\n // Not an error; returned on success\n //\n // HTTP Mapping: 200 OK\n OK: 200,\n\n // The operation was canceled, typically by the caller.\n //\n // HTTP Mapping: 499 Client Closed Request\n CANCELLED: 499,\n\n // Unknown error. For example, this error may be returned when\n // a `Status` value received from another address space belongs to\n // an error space that is not known in this address space. Also,\n // errors raised by APIs that do not return enough error information\n // may be converted to this error.\n //\n // HTTP Mapping: 500 Internal Server Error\n UNKNOWN: 500,\n\n // The client specified an invalid argument. Note that this differs\n // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments\n // that are problematic regardless of the state of the system\n // (e.g., a malformed file name).\n //\n // HTTP Mapping: 400 Bad Request\n INVALID_ARGUMENT: 400,\n\n // The deadline expired before the operation could complete. For operations\n // that change the state of the system, this error may be returned\n // even if the operation has completed successfully. For example, a\n // successful response from a server could have been delayed long\n // enough for the deadline to expire.\n //\n // HTTP Mapping: 504 Gateway Timeout\n DEADLINE_EXCEEDED: 504,\n\n // Some requested entity (e.g., file or directory) was not found.\n //\n // Note to server developers: if a request is denied for an entire class\n // of users, such as gradual feature rollout or undocumented whitelist,\n // `NOT_FOUND` may be used. If a request is denied for some users within\n // a class of users, such as user-based access control, `PERMISSION_DENIED`\n // must be used.\n //\n // HTTP Mapping: 404 Not Found\n NOT_FOUND: 404,\n\n // The entity that a client attempted to create (e.g., file or directory)\n // already exists.\n //\n // HTTP Mapping: 409 Conflict\n ALREADY_EXISTS: 409,\n\n // The caller does not have permission to execute the specified\n // operation. `PERMISSION_DENIED` must not be used for rejections\n // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`\n // instead for those errors). `PERMISSION_DENIED` must not be\n // used if the caller can not be identified (use `UNAUTHENTICATED`\n // instead for those errors). This error code does not imply the\n // request is valid or the requested entity exists or satisfies\n // other pre-conditions.\n //\n // HTTP Mapping: 403 Forbidden\n PERMISSION_DENIED: 403,\n\n // Some resource has been exhausted, perhaps a per-user quota, or\n // perhaps the entire file system is out of space.\n //\n // HTTP Mapping: 429 Too Many Requests\n RESOURCE_EXHAUSTED: 429,\n\n // The operation was rejected because the system is not in a state\n // required for the operation's execution. For example, the directory\n // to be deleted is non-empty, a rmdir operation is applied to\n // a non-directory, etc.\n //\n // Service implementors can use the following guidelines to decide\n // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:\n // (a) Use `UNAVAILABLE` if the client can retry just the failing call.\n // (b) Use `ABORTED` if the client should retry at a higher level\n // (e.g., when a client-specified test-and-set fails, indicating the\n // client should restart a read-modify-write sequence).\n // (c) Use `FAILED_PRECONDITION` if the client should not retry until\n // the system state has been explicitly fixed. E.g., if a \"rmdir\"\n // fails because the directory is non-empty, `FAILED_PRECONDITION`\n // should be returned since the client should not retry unless\n // the files are deleted from the directory.\n //\n // HTTP Mapping: 400 Bad Request\n FAILED_PRECONDITION: 400,\n\n // The operation was aborted, typically due to a concurrency issue such as\n // a sequencer check failure or transaction abort.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 409 Conflict\n ABORTED: 409,\n\n // The operation was attempted past the valid range. E.g., seeking or\n // reading past end-of-file.\n //\n // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may\n // be fixed if the system state changes. For example, a 32-bit file\n // system will generate `INVALID_ARGUMENT` if asked to read at an\n // offset that is not in the range [0,2^32-1], but it will generate\n // `OUT_OF_RANGE` if asked to read from an offset past the current\n // file size.\n //\n // There is a fair bit of overlap between `FAILED_PRECONDITION` and\n // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific\n // error) when it applies so that callers who are iterating through\n // a space can easily look for an `OUT_OF_RANGE` error to detect when\n // they are done.\n //\n // HTTP Mapping: 400 Bad Request\n OUT_OF_RANGE: 400,\n\n // The operation is not implemented or is not supported/enabled in this\n // service.\n //\n // HTTP Mapping: 501 Not Implemented\n UNIMPLEMENTED: 501,\n\n // Internal errors. This means that some invariants expected by the\n // underlying system have been broken. This error code is reserved\n // for serious errors.\n //\n // HTTP Mapping: 500 Internal Server Error\n INTERNAL: 500,\n\n // The service is currently unavailable. This is most likely a\n // transient condition, which can be corrected by retrying with\n // a backoff. Note that it is not always safe to retry\n // non-idempotent operations.\n //\n // See the guidelines above for deciding between `FAILED_PRECONDITION`,\n // `ABORTED`, and `UNAVAILABLE`.\n //\n // HTTP Mapping: 503 Service Unavailable\n UNAVAILABLE: 503,\n\n // Unrecoverable data loss or corruption.\n //\n // HTTP Mapping: 500 Internal Server Error\n DATA_LOSS: 500,\n\n // The request does not have valid authentication credentials for the\n // operation.\n //\n // HTTP Mapping: 401 Unauthorized\n UNAUTHENTICATED: 401,\n\n // The request method is not supported by the server and cannot be handled.\n //\n // HTTP Mapping: 405 Method Not Allowed\n METHOD_NOT_ALLOWED: 405,\n} as const;\n\nexport const DEFAULT_MESSAGES: Record<keyof typeof Code, string> = {\n OK: 'OK',\n CANCELLED: 'The operation was cancelled',\n UNKNOWN: 'Unknown error',\n INVALID_ARGUMENT: 'The client specified an invalid argument',\n DEADLINE_EXCEEDED: 'The deadline expired before the operation could complete',\n NOT_FOUND: 'Some requested entity was not found',\n ALREADY_EXISTS: 'The entity that a client attempted to create already exists',\n PERMISSION_DENIED: 'The caller does not have permission to execute the specified operation',\n RESOURCE_EXHAUSTED: 'Some resource has been exhausted',\n FAILED_PRECONDITION:\n \"The operation was rejected because the system is not in a state required for the operation's execution\",\n ABORTED: 'The operation was aborted',\n OUT_OF_RANGE: 'The operation was attempted past the valid range',\n UNIMPLEMENTED: 'The operation is not implemented or is not supported/enabled in this service',\n INTERNAL: 'Internal errors',\n UNAVAILABLE: 'The service is currently unavailable',\n DATA_LOSS: 'Unrecoverable data loss or corruption',\n UNAUTHENTICATED: 'The request does not have valid authentication credentials for the operation',\n METHOD_NOT_ALLOWED: 'The request method is not supported by the server and cannot be handled',\n};\n\nexport interface ErrorBody {\n error: {\n code: number;\n status: keyof typeof Code;\n message: string;\n details: Detail[];\n };\n}\n\nexport class StatusError extends Error {\n readonly status: number;\n readonly body?: ErrorBody;\n\n constructor(status: number, body?: ErrorBody) {\n super(body?.error.message ?? `Status Error: ${status}`);\n this.name = 'StatusError';\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, StatusError.prototype);\n }\n}\n\nexport class StatusCode {\n code: keyof typeof Code;\n message?: string;\n private constructor(code: keyof typeof Code, message?: string) {\n this.code = code;\n this.message = message;\n }\n\n static of(code: keyof typeof Code, message?: string) {\n return new StatusCode(code, message ?? DEFAULT_MESSAGES[code]);\n }\n\n body(details?: Details): ErrorBody {\n return {\n error: {\n code: Code[this.code],\n status: this.code,\n message: this.message ?? '',\n details: details?.list ?? [],\n },\n };\n }\n\n error(details?: Details): Error {\n const body = this.body(details);\n if (Status.adapter) return Status.adapter(Code[this.code], body);\n return new StatusError(Code[this.code], body);\n }\n\n response(details?: Details): Response {\n const body = this.body(details);\n return Response.json(body, { status: body.error.code });\n }\n}\n\nexport class Status {\n static adapter?: (status: number, response: ErrorBody) => Error;\n\n static ok = (message?: string) => StatusCode.of('OK', message);\n static cancelled = (message?: string) => StatusCode.of('CANCELLED', message);\n static unknown = (message?: string) => StatusCode.of('UNKNOWN', message);\n static invalidArgument = (message?: string) => StatusCode.of('INVALID_ARGUMENT', message);\n static deadlineExceeded = (message?: string) => StatusCode.of('DEADLINE_EXCEEDED', message);\n static notFound = (message?: string) => StatusCode.of('NOT_FOUND', message);\n static alreadyExists = (message?: string) => StatusCode.of('ALREADY_EXISTS', message);\n static permissionDenied = (message?: string) => StatusCode.of('PERMISSION_DENIED', message);\n static unauthorized = (message?: string) => StatusCode.of('UNAUTHENTICATED', message);\n static resourceExhausted = (message?: string) => StatusCode.of('RESOURCE_EXHAUSTED', message);\n static failedPrecondition = (message?: string) => StatusCode.of('FAILED_PRECONDITION', message);\n static aborted = (message?: string) => StatusCode.of('ABORTED', message);\n static outOfRange = (message?: string) => StatusCode.of('OUT_OF_RANGE', message);\n static unimplemented = (message?: string) => StatusCode.of('UNIMPLEMENTED', message);\n static internal = (message?: string) => StatusCode.of('INTERNAL', message);\n static unavailable = (message?: string) => StatusCode.of('UNAVAILABLE', message);\n static dataLoss = (message?: string) => StatusCode.of('DATA_LOSS', message);\n static methodNotAllowed = (message?: string) => StatusCode.of('METHOD_NOT_ALLOWED', message);\n}\n"],"mappings":";AAEA,MAAa,OAAO;CAIlB,IAAI;CAKJ,WAAW;CASX,SAAS;CAQT,kBAAkB;CASlB,mBAAmB;CAWnB,WAAW;CAMX,gBAAgB;CAYhB,mBAAmB;CAMnB,oBAAoB;CAoBpB,qBAAqB;CASrB,SAAS;CAmBT,cAAc;CAMd,eAAe;CAOf,UAAU;CAWV,aAAa;CAKb,WAAW;CAMX,iBAAiB;CAKjB,oBAAoB;AACtB;AAEA,MAAa,mBAAsD;CACjE,IAAI;CACJ,WAAW;CACX,SAAS;CACT,kBAAkB;CAClB,mBAAmB;CACnB,WAAW;CACX,gBAAgB;CAChB,mBAAmB;CACnB,oBAAoB;CACpB,qBACE;CACF,SAAS;CACT,cAAc;CACd,eAAe;CACf,UAAU;CACV,aAAa;CACb,WAAW;CACX,iBAAiB;CACjB,oBAAoB;AACtB;AAWA,IAAa,cAAb,MAAa,oBAAoB,MAAM;CACrC;CACA;CAEA,YAAY,QAAgB,MAAkB;EAC5C,MAAM,MAAM,MAAM,WAAW,iBAAiB,QAAQ;EACtD,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,OAAO,eAAe,MAAM,YAAY,SAAS;CACnD;AACF;AAEA,IAAa,aAAb,MAAa,WAAW;CACtB;CACA;CACA,YAAoB,MAAyB,SAAkB;EAC7D,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;CAEA,OAAO,GAAG,MAAyB,SAAkB;EACnD,OAAO,IAAI,WAAW,MAAM,WAAW,iBAAiB,KAAK;CAC/D;CAEA,KAAK,SAA8B;EACjC,OAAO,EACL,OAAO;GACL,MAAM,KAAK,KAAK;GAChB,QAAQ,KAAK;GACb,SAAS,K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W,GAAG,eAAe,OAAO;CAC/E,OAAO,YAAY,YAAqB,WAAW,GAAG,aAAa,OAAO;CAC1E,OAAO,oBAAoB,YAAqB,WAAW,GAAG,sBAAsB,OAAO;AAC7F"}
|
package/dist/hono/handler.cjs
CHANGED
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_error_detail = require("../error/detail.cjs");
|
|
3
3
|
const require_error_status = require("../error/status.cjs");
|
|
4
|
+
let _shware_utils = require("@shware/utils");
|
|
5
|
+
let hono_http_exception = require("hono/http-exception");
|
|
4
6
|
//#region src/hono/handler.ts
|
|
7
|
+
/**
|
|
8
|
+
* `Code` maps a name to an HTTP status, and that mapping is not injective: 400 is INVALID_ARGUMENT,
|
|
9
|
+
* FAILED_PRECONDITION and OUT_OF_RANGE alike. Reversing it therefore needs a tiebreaker for the
|
|
10
|
+
* statuses several codes share — the rest is derived, so new entries in `Code` come along for free.
|
|
11
|
+
*/
|
|
12
|
+
const CANONICAL_CODE = {
|
|
13
|
+
400: "INVALID_ARGUMENT",
|
|
14
|
+
409: "ALREADY_EXISTS",
|
|
15
|
+
500: "INTERNAL"
|
|
16
|
+
};
|
|
17
|
+
const CODE_BY_HTTP_STATUS = {
|
|
18
|
+
...Object.fromEntries(Object.entries(require_error_status.Code).map(([name, status]) => [status, name])),
|
|
19
|
+
...CANONICAL_CODE
|
|
20
|
+
};
|
|
21
|
+
/** Canonical code for errors that only carry an HTTP status, such as hono's `HTTPException`. */
|
|
22
|
+
function toStatusCode(status, message) {
|
|
23
|
+
const code = CODE_BY_HTTP_STATUS[status] ?? (status < 500 ? "INVALID_ARGUMENT" : "INTERNAL");
|
|
24
|
+
return require_error_status.StatusCode.of(code, (0, _shware_utils.hasText)(message) ? message : void 0);
|
|
25
|
+
}
|
|
26
|
+
function summarize(error) {
|
|
27
|
+
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
28
|
+
return String(error);
|
|
29
|
+
}
|
|
5
30
|
function isAxiosError(payload) {
|
|
6
31
|
return payload !== null && typeof payload === "object" && "isAxiosError" in payload && payload.isAxiosError === true;
|
|
7
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* `instanceof` alone is not enough: two copies of this package (duplicated in a lockfile, or one
|
|
35
|
+
* bundled into a dependency) produce distinct classes, and `Status.adapter` may swap in a
|
|
36
|
+
* host-defined error class entirely. Fall back to recognizing the error by shape.
|
|
37
|
+
*/
|
|
38
|
+
function isStatusError(payload) {
|
|
39
|
+
if (payload instanceof require_error_status.StatusError) return true;
|
|
40
|
+
if (payload === null || typeof payload !== "object") return false;
|
|
41
|
+
const { status, body } = payload;
|
|
42
|
+
return typeof status === "number" && typeof body?.error?.code === "number";
|
|
43
|
+
}
|
|
8
44
|
function errorHandler(error, c) {
|
|
9
45
|
const requestId = c.get("requestId");
|
|
10
46
|
const servingData = `${c.req.method}: ${c.req.path}`;
|
|
@@ -12,16 +48,26 @@ function errorHandler(error, c) {
|
|
|
12
48
|
requestId,
|
|
13
49
|
servingData
|
|
14
50
|
});
|
|
15
|
-
if (error
|
|
16
|
-
error.body
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
51
|
+
if (isStatusError(error)) {
|
|
52
|
+
const body = error.body ?? require_error_status.Status.internal().body();
|
|
53
|
+
body.error.details.push(...details.list);
|
|
54
|
+
(error.status >= 500 ? console.error : console.warn)(servingData, JSON.stringify(body.error));
|
|
55
|
+
return c.json(body, error.status);
|
|
56
|
+
}
|
|
57
|
+
if (c.req.raw.signal.aborted) {
|
|
58
|
+
console.warn(`Client closed request: ${servingData}`, summarize(error));
|
|
59
|
+
return require_error_status.Status.cancelled().response(details);
|
|
60
|
+
}
|
|
61
|
+
if (error instanceof hono_http_exception.HTTPException) {
|
|
62
|
+
(error.status >= 500 ? console.error : console.warn)(`HTTP exception: ${servingData}`, error.status, error.message);
|
|
63
|
+
if (error.res) return error.res;
|
|
64
|
+
return toStatusCode(error.status, error.message).response(details);
|
|
21
65
|
}
|
|
22
66
|
if (isAxiosError(error)) {
|
|
23
|
-
console.error({
|
|
24
|
-
|
|
67
|
+
console.error(`Axios error: ${servingData}`, {
|
|
68
|
+
requestId,
|
|
69
|
+
code: error.code,
|
|
70
|
+
status: error.status ?? error.response?.status,
|
|
25
71
|
message: error.message,
|
|
26
72
|
request: {
|
|
27
73
|
method: error.config?.method,
|
|
@@ -32,11 +78,12 @@ function errorHandler(error, c) {
|
|
|
32
78
|
});
|
|
33
79
|
return require_error_status.Status.internal("Axios error").response(details);
|
|
34
80
|
}
|
|
35
|
-
console.error(`Unknown error: ${servingData}`, error);
|
|
81
|
+
console.error(`Unknown error: ${servingData}`, requestId, error);
|
|
36
82
|
return require_error_status.Status.internal("Unknown error").response(details);
|
|
37
83
|
}
|
|
38
84
|
//#endregion
|
|
39
85
|
exports.errorHandler = errorHandler;
|
|
40
86
|
exports.isAxiosError = isAxiosError;
|
|
87
|
+
exports.isStatusError = isStatusError;
|
|
41
88
|
|
|
42
89
|
//# sourceMappingURL=handler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.cjs","names":["
|
|
1
|
+
{"version":3,"file":"handler.cjs","names":["Code","StatusCode","StatusError","Details","Status","HTTPException"],"sources":["../../src/hono/handler.ts"],"sourcesContent":["import { hasText } from '@shware/utils';\nimport type { Context } from 'hono';\nimport { HTTPException } from 'hono/http-exception';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport type { Bindings, HTTPResponseError } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport { Details } from '../error/detail';\nimport { Code, Status, StatusCode, StatusError } from '../error/status';\n\nexport type Env = {\n Variables: RequestIdVariables;\n Bindings?: Bindings;\n};\n\ntype AxiosError = {\n code?: string;\n cause?: unknown;\n status?: number;\n message?: string;\n isAxiosError: boolean;\n response?: {\n data: unknown;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n };\n config?: { url?: string; data?: unknown; method?: string; headers?: Record<string, string> };\n};\n\n/**\n * `Code` maps a name to an HTTP status, and that mapping is not injective: 400 is INVALID_ARGUMENT,\n * FAILED_PRECONDITION and OUT_OF_RANGE alike. Reversing it therefore needs a tiebreaker for the\n * statuses several codes share — the rest is derived, so new entries in `Code` come along for free.\n */\nconst CANONICAL_CODE: Record<number, keyof typeof Code> = {\n 400: 'INVALID_ARGUMENT',\n 409: 'ALREADY_EXISTS',\n 500: 'INTERNAL',\n};\n\nconst CODE_BY_HTTP_STATUS: Record<number, keyof typeof Code> = {\n ...Object.fromEntries(Object.entries(Code).map(([name, status]) => [status, name])),\n ...CANONICAL_CODE,\n};\n\n/** Canonical code for errors that only carry an HTTP status, such as hono's `HTTPException`. */\nfunction toStatusCode(status: number, message?: string): StatusCode {\n const code = CODE_BY_HTTP_STATUS[status] ?? (status < 500 ? 'INVALID_ARGUMENT' : 'INTERNAL');\n return StatusCode.of(code, hasText(message) ? message : undefined);\n}\n\nfunction summarize(error: unknown): string {\n if (error instanceof Error) return `${error.name}: ${error.message}`;\n return String(error);\n}\n\nexport function isAxiosError(payload: unknown): payload is AxiosError {\n return (\n payload !== null &&\n typeof payload === 'object' &&\n 'isAxiosError' in payload &&\n payload.isAxiosError === true\n );\n}\n\n/**\n * `instanceof` alone is not enough: two copies of this package (duplicated in a lockfile, or one\n * bundled into a dependency) produce distinct classes, and `Status.adapter` may swap in a\n * host-defined error class entirely. Fall back to recognizing the error by shape.\n */\nexport function isStatusError(payload: unknown): payload is StatusError {\n if (payload instanceof StatusError) return true;\n if (payload === null || typeof payload !== 'object') return false;\n const { status, body } = payload as { status?: unknown; body?: { error?: { code?: unknown } } };\n return typeof status === 'number' && typeof body?.error?.code === 'number';\n}\n\nexport function errorHandler<E extends Env = never>(\n error: Error | HTTPResponseError,\n c: Context<E>\n): Response | Promise<Response> {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.path}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n\n if (isStatusError(error)) {\n const body = error.body ?? Status.internal().body();\n body.error.details.push(...details.list);\n // Only 5xx is a server fault; logging expected 4xx at error level drowns out the real ones.\n // Field violations travel inside `details`, so one line carries the whole error.\n const log = error.status >= 500 ? console.error : console.warn;\n log(servingData, JSON.stringify(body.error));\n return c.json(body, error.status as ContentfulStatusCode);\n }\n\n // The client vanished mid-request: tab closed, navigation, or an aborted fetch. Whatever we\n // return is discarded, and nothing failed on our side, so keep it to one terse line. Shows up\n // in local dev because the request body is streamed straight off the socket — a truncated body\n // fails to parse; platforms that buffer the whole request before invoking (API Gateway, Lambda\n // function URLs) never hand us a partial request in the first place.\n if (c.req.raw.signal.aborted) {\n console.warn(`Client closed request: ${servingData}`, summarize(error));\n return Status.cancelled().response(details);\n }\n\n if (error instanceof HTTPException) {\n // Middleware such as `bearerAuth` attaches a prepared response carrying headers the client\n // needs (`WWW-Authenticate`, …); hand that back untouched instead of re-wrapping it.\n const log = error.status >= 500 ? console.error : console.warn;\n log(`HTTP exception: ${servingData}`, error.status, error.message);\n if (error.res) return error.res;\n return toStatusCode(error.status, error.message).response(details);\n }\n\n if (isAxiosError(error)) {\n console.error(`Axios error: ${servingData}`, {\n requestId,\n code: error.code,\n status: error.status ?? error.response?.status,\n message: error.message,\n request: {\n method: error.config?.method,\n url: error.config?.url,\n data: error.config?.data,\n },\n response: { data: error.response?.data },\n });\n return Status.internal('Axios error').response(details);\n }\n\n console.error(`Unknown error: ${servingData}`, requestId, error);\n return Status.internal('Unknown error').response(details);\n}\n"],"mappings":";;;;;;;;;;;AAkCA,MAAM,iBAAoD;CACxD,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,MAAM,sBAAyD;CAC7D,GAAG,OAAO,YAAY,OAAO,QAAQA,qBAAAA,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CAAC,QAAQ,IAAI,CAAC,CAAC;CAClF,GAAG;AACL;;AAGA,SAAS,aAAa,QAAgB,SAA8B;CAClE,MAAM,OAAO,oB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AS,OAAO;CAC5C;CAEA,IAAI,iBAAiBC,oBAAAA,eAAe;EAIlC,CADY,MAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,KAAA,CACtD,mBAAmB,eAAe,MAAM,QAAQ,MAAM,OAAO;EACjE,IAAI,MAAM,KAAK,OAAO,MAAM;EAC5B,OAAO,aAAa,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO;CACnE;CAEA,IAAI,aAAa,KAAK,GAAG;EACvB,QAAQ,MAAM,gBAAgB,eAAe;GAC3C;GACA,MAAM,MAAM;GACZ,QAAQ,MAAM,UAAU,MAAM,UAAU;GACxC,SAAS,MAAM;GACf,SAAS;IACP,QAAQ,MAAM,QAAQ;IACtB,KAAK,MAAM,QAAQ;IACnB,MAAM,MAAM,QAAQ;GACtB;GACA,UAAU,EAAE,MAAM,MAAM,UAAU,KAAK;EACzC,CAAC;EACD,OAAOD,qBAAAA,OAAO,SAAS,aAAa,CAAC,CAAC,SAAS,OAAO;CACxD;CAEA,QAAQ,MAAM,kBAAkB,eAAe,WAAW,KAAK;CAC/D,OAAOA,qBAAAA,OAAO,SAAS,eAAe,CAAC,CAAC,SAAS,OAAO;AAC1D"}
|
package/dist/hono/handler.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StatusError } from "../error/status.cjs";
|
|
1
2
|
import { Context } from "hono";
|
|
2
3
|
import { RequestIdVariables } from "hono/request-id";
|
|
3
4
|
import { Bindings, HTTPResponseError } from "hono/types";
|
|
@@ -26,7 +27,13 @@ type AxiosError = {
|
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
29
|
declare function isAxiosError(payload: unknown): payload is AxiosError;
|
|
30
|
+
/**
|
|
31
|
+
* `instanceof` alone is not enough: two copies of this package (duplicated in a lockfile, or one
|
|
32
|
+
* bundled into a dependency) produce distinct classes, and `Status.adapter` may swap in a
|
|
33
|
+
* host-defined error class entirely. Fall back to recognizing the error by shape.
|
|
34
|
+
*/
|
|
35
|
+
declare function isStatusError(payload: unknown): payload is StatusError;
|
|
29
36
|
declare function errorHandler<E extends Env = never>(error: Error | HTTPResponseError, c: Context<E>): Response | Promise<Response>;
|
|
30
37
|
//#endregion
|
|
31
|
-
export { Env, errorHandler, isAxiosError };
|
|
38
|
+
export { Env, errorHandler, isAxiosError, isStatusError };
|
|
32
39
|
//# sourceMappingURL=handler.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.cts","names":[],"sources":["../../src/hono/handler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.cts","names":[],"sources":["../../src/hono/handler.ts"],"mappings":";;;;;KASY;EACV,WAAW;EACX,WAAW;;KAGR;EACH;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA,SAAS;;EAEX;IAAW;IAAc;IAAgB;IAAiB,UAAU;;;iBA8BtD,aAAa,mBAAmB,WAAW;;;;;;iBAc3C,cAAc,mBAAmB,WAAW;iBAO5C,aAAa,UAAU,aACrC,OAAO,QAAQ,mBACf,GAAG,QAAQ,KACV,WAAW,QAAQ"}
|
package/dist/hono/handler.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StatusError } from "../error/status.mjs";
|
|
1
2
|
import { Context } from "hono";
|
|
2
3
|
import { RequestIdVariables } from "hono/request-id";
|
|
3
4
|
import { Bindings, HTTPResponseError } from "hono/types";
|
|
@@ -26,7 +27,13 @@ type AxiosError = {
|
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
29
|
declare function isAxiosError(payload: unknown): payload is AxiosError;
|
|
30
|
+
/**
|
|
31
|
+
* `instanceof` alone is not enough: two copies of this package (duplicated in a lockfile, or one
|
|
32
|
+
* bundled into a dependency) produce distinct classes, and `Status.adapter` may swap in a
|
|
33
|
+
* host-defined error class entirely. Fall back to recognizing the error by shape.
|
|
34
|
+
*/
|
|
35
|
+
declare function isStatusError(payload: unknown): payload is StatusError;
|
|
29
36
|
declare function errorHandler<E extends Env = never>(error: Error | HTTPResponseError, c: Context<E>): Response | Promise<Response>;
|
|
30
37
|
//#endregion
|
|
31
|
-
export { Env, errorHandler, isAxiosError };
|
|
38
|
+
export { Env, errorHandler, isAxiosError, isStatusError };
|
|
32
39
|
//# sourceMappingURL=handler.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.mts","names":[],"sources":["../../src/hono/handler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.mts","names":[],"sources":["../../src/hono/handler.ts"],"mappings":";;;;;KASY;EACV,WAAW;EACX,WAAW;;KAGR;EACH;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA,SAAS;;EAEX;IAAW;IAAc;IAAgB;IAAiB,UAAU;;;iBA8BtD,aAAa,mBAAmB,WAAW;;;;;;iBAc3C,cAAc,mBAAmB,WAAW;iBAO5C,aAAa,UAAU,aACrC,OAAO,QAAQ,mBACf,GAAG,QAAQ,KACV,WAAW,QAAQ"}
|
package/dist/hono/handler.mjs
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Status, StatusError } from "../error/status.mjs";
|
|
1
|
+
import { Details } from "../error/detail.mjs";
|
|
2
|
+
import { Code, Status, StatusCode, StatusError } from "../error/status.mjs";
|
|
3
|
+
import { hasText } from "@shware/utils";
|
|
4
|
+
import { HTTPException } from "hono/http-exception";
|
|
3
5
|
//#region src/hono/handler.ts
|
|
6
|
+
/**
|
|
7
|
+
* `Code` maps a name to an HTTP status, and that mapping is not injective: 400 is INVALID_ARGUMENT,
|
|
8
|
+
* FAILED_PRECONDITION and OUT_OF_RANGE alike. Reversing it therefore needs a tiebreaker for the
|
|
9
|
+
* statuses several codes share — the rest is derived, so new entries in `Code` come along for free.
|
|
10
|
+
*/
|
|
11
|
+
const CANONICAL_CODE = {
|
|
12
|
+
400: "INVALID_ARGUMENT",
|
|
13
|
+
409: "ALREADY_EXISTS",
|
|
14
|
+
500: "INTERNAL"
|
|
15
|
+
};
|
|
16
|
+
const CODE_BY_HTTP_STATUS = {
|
|
17
|
+
...Object.fromEntries(Object.entries(Code).map(([name, status]) => [status, name])),
|
|
18
|
+
...CANONICAL_CODE
|
|
19
|
+
};
|
|
20
|
+
/** Canonical code for errors that only carry an HTTP status, such as hono's `HTTPException`. */
|
|
21
|
+
function toStatusCode(status, message) {
|
|
22
|
+
const code = CODE_BY_HTTP_STATUS[status] ?? (status < 500 ? "INVALID_ARGUMENT" : "INTERNAL");
|
|
23
|
+
return StatusCode.of(code, hasText(message) ? message : void 0);
|
|
24
|
+
}
|
|
25
|
+
function summarize(error) {
|
|
26
|
+
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
27
|
+
return String(error);
|
|
28
|
+
}
|
|
4
29
|
function isAxiosError(payload) {
|
|
5
30
|
return payload !== null && typeof payload === "object" && "isAxiosError" in payload && payload.isAxiosError === true;
|
|
6
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* `instanceof` alone is not enough: two copies of this package (duplicated in a lockfile, or one
|
|
34
|
+
* bundled into a dependency) produce distinct classes, and `Status.adapter` may swap in a
|
|
35
|
+
* host-defined error class entirely. Fall back to recognizing the error by shape.
|
|
36
|
+
*/
|
|
37
|
+
function isStatusError(payload) {
|
|
38
|
+
if (payload instanceof StatusError) return true;
|
|
39
|
+
if (payload === null || typeof payload !== "object") return false;
|
|
40
|
+
const { status, body } = payload;
|
|
41
|
+
return typeof status === "number" && typeof body?.error?.code === "number";
|
|
42
|
+
}
|
|
7
43
|
function errorHandler(error, c) {
|
|
8
44
|
const requestId = c.get("requestId");
|
|
9
45
|
const servingData = `${c.req.method}: ${c.req.path}`;
|
|
@@ -11,16 +47,26 @@ function errorHandler(error, c) {
|
|
|
11
47
|
requestId,
|
|
12
48
|
servingData
|
|
13
49
|
});
|
|
14
|
-
if (error
|
|
15
|
-
error.body
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
if (isStatusError(error)) {
|
|
51
|
+
const body = error.body ?? Status.internal().body();
|
|
52
|
+
body.error.details.push(...details.list);
|
|
53
|
+
(error.status >= 500 ? console.error : console.warn)(servingData, JSON.stringify(body.error));
|
|
54
|
+
return c.json(body, error.status);
|
|
55
|
+
}
|
|
56
|
+
if (c.req.raw.signal.aborted) {
|
|
57
|
+
console.warn(`Client closed request: ${servingData}`, summarize(error));
|
|
58
|
+
return Status.cancelled().response(details);
|
|
59
|
+
}
|
|
60
|
+
if (error instanceof HTTPException) {
|
|
61
|
+
(error.status >= 500 ? console.error : console.warn)(`HTTP exception: ${servingData}`, error.status, error.message);
|
|
62
|
+
if (error.res) return error.res;
|
|
63
|
+
return toStatusCode(error.status, error.message).response(details);
|
|
20
64
|
}
|
|
21
65
|
if (isAxiosError(error)) {
|
|
22
|
-
console.error({
|
|
23
|
-
|
|
66
|
+
console.error(`Axios error: ${servingData}`, {
|
|
67
|
+
requestId,
|
|
68
|
+
code: error.code,
|
|
69
|
+
status: error.status ?? error.response?.status,
|
|
24
70
|
message: error.message,
|
|
25
71
|
request: {
|
|
26
72
|
method: error.config?.method,
|
|
@@ -31,10 +77,10 @@ function errorHandler(error, c) {
|
|
|
31
77
|
});
|
|
32
78
|
return Status.internal("Axios error").response(details);
|
|
33
79
|
}
|
|
34
|
-
console.error(`Unknown error: ${servingData}`, error);
|
|
80
|
+
console.error(`Unknown error: ${servingData}`, requestId, error);
|
|
35
81
|
return Status.internal("Unknown error").response(details);
|
|
36
82
|
}
|
|
37
83
|
//#endregion
|
|
38
|
-
export { errorHandler, isAxiosError };
|
|
84
|
+
export { errorHandler, isAxiosError, isStatusError };
|
|
39
85
|
|
|
40
86
|
//# sourceMappingURL=handler.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.mjs","names":[],"sources":["../../src/hono/handler.ts"],"sourcesContent":["import type { Context } from 'hono';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport type { Bindings, HTTPResponseError } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport {
|
|
1
|
+
{"version":3,"file":"handler.mjs","names":[],"sources":["../../src/hono/handler.ts"],"sourcesContent":["import { hasText } from '@shware/utils';\nimport type { Context } from 'hono';\nimport { HTTPException } from 'hono/http-exception';\nimport type { RequestIdVariables } from 'hono/request-id';\nimport type { Bindings, HTTPResponseError } from 'hono/types';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\nimport { Details } from '../error/detail';\nimport { Code, Status, StatusCode, StatusError } from '../error/status';\n\nexport type Env = {\n Variables: RequestIdVariables;\n Bindings?: Bindings;\n};\n\ntype AxiosError = {\n code?: string;\n cause?: unknown;\n status?: number;\n message?: string;\n isAxiosError: boolean;\n response?: {\n data: unknown;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n };\n config?: { url?: string; data?: unknown; method?: string; headers?: Record<string, string> };\n};\n\n/**\n * `Code` maps a name to an HTTP status, and that mapping is not injective: 400 is INVALID_ARGUMENT,\n * FAILED_PRECONDITION and OUT_OF_RANGE alike. Reversing it therefore needs a tiebreaker for the\n * statuses several codes share — the rest is derived, so new entries in `Code` come along for free.\n */\nconst CANONICAL_CODE: Record<number, keyof typeof Code> = {\n 400: 'INVALID_ARGUMENT',\n 409: 'ALREADY_EXISTS',\n 500: 'INTERNAL',\n};\n\nconst CODE_BY_HTTP_STATUS: Record<number, keyof typeof Code> = {\n ...Object.fromEntries(Object.entries(Code).map(([name, status]) => [status, name])),\n ...CANONICAL_CODE,\n};\n\n/** Canonical code for errors that only carry an HTTP status, such as hono's `HTTPException`. */\nfunction toStatusCode(status: number, message?: string): StatusCode {\n const code = CODE_BY_HTTP_STATUS[status] ?? (status < 500 ? 'INVALID_ARGUMENT' : 'INTERNAL');\n return StatusCode.of(code, hasText(message) ? message : undefined);\n}\n\nfunction summarize(error: unknown): string {\n if (error instanceof Error) return `${error.name}: ${error.message}`;\n return String(error);\n}\n\nexport function isAxiosError(payload: unknown): payload is AxiosError {\n return (\n payload !== null &&\n typeof payload === 'object' &&\n 'isAxiosError' in payload &&\n payload.isAxiosError === true\n );\n}\n\n/**\n * `instanceof` alone is not enough: two copies of this package (duplicated in a lockfile, or one\n * bundled into a dependency) produce distinct classes, and `Status.adapter` may swap in a\n * host-defined error class entirely. Fall back to recognizing the error by shape.\n */\nexport function isStatusError(payload: unknown): payload is StatusError {\n if (payload instanceof StatusError) return true;\n if (payload === null || typeof payload !== 'object') return false;\n const { status, body } = payload as { status?: unknown; body?: { error?: { code?: unknown } } };\n return typeof status === 'number' && typeof body?.error?.code === 'number';\n}\n\nexport function errorHandler<E extends Env = never>(\n error: Error | HTTPResponseError,\n c: Context<E>\n): Response | Promise<Response> {\n const requestId = c.get('requestId');\n const servingData = `${c.req.method}: ${c.req.path}`;\n const details = Details.new().requestInfo({ requestId, servingData });\n\n if (isStatusError(error)) {\n const body = error.body ?? Status.internal().body();\n body.error.details.push(...details.list);\n // Only 5xx is a server fault; logging expected 4xx at error level drowns out the real ones.\n // Field violations travel inside `details`, so one line carries the whole error.\n const log = error.status >= 500 ? console.error : console.warn;\n log(servingData, JSON.stringify(body.error));\n return c.json(body, error.status as ContentfulStatusCode);\n }\n\n // The client vanished mid-request: tab closed, navigation, or an aborted fetch. Whatever we\n // return is discarded, and nothing failed on our side, so keep it to one terse line. Shows up\n // in local dev because the request body is streamed straight off the socket — a truncated body\n // fails to parse; platforms that buffer the whole request before invoking (API Gateway, Lambda\n // function URLs) never hand us a partial request in the first place.\n if (c.req.raw.signal.aborted) {\n console.warn(`Client closed request: ${servingData}`, summarize(error));\n return Status.cancelled().response(details);\n }\n\n if (error instanceof HTTPException) {\n // Middleware such as `bearerAuth` attaches a prepared response carrying headers the client\n // needs (`WWW-Authenticate`, …); hand that back untouched instead of re-wrapping it.\n const log = error.status >= 500 ? console.error : console.warn;\n log(`HTTP exception: ${servingData}`, error.status, error.message);\n if (error.res) return error.res;\n return toStatusCode(error.status, error.message).response(details);\n }\n\n if (isAxiosError(error)) {\n console.error(`Axios error: ${servingData}`, {\n requestId,\n code: error.code,\n status: error.status ?? error.response?.status,\n message: error.message,\n request: {\n method: error.config?.method,\n url: error.config?.url,\n data: error.config?.data,\n },\n response: { data: error.response?.data },\n });\n return Status.internal('Axios error').response(details);\n }\n\n console.error(`Unknown error: ${servingData}`, requestId, error);\n return Status.internal('Unknown error').response(details);\n}\n"],"mappings":";;;;;;;;;;AAkCA,MAAM,iBAAoD;CACxD,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,MAAM,sBAAyD;CAC7D,GAAG,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY,CAAC,QAAQ,IAAI,CAAC,CAAC;CAClF,GAAG;AACL;;AAGA,SAAS,aAAa,QAAgB,SAA8B;CAClE,MAAM,OAAO,oBAAoB,YAAY,SAAS,MAAM,qBAAqB;CACjF,OAAO,WAAW,GAAG,MAAM,QAAQ,OAAO,IAAI,UAAU,KAAA,CAAS;AACnE;AAEA,SAAS,UAAU,OAAwB;CACzC,IAAI,iBAAiB,OAAO,OAAO,GAAG,MAAM,KAAK,IAAI,MAAM;CAC3D,OAAO,OAAO,KAAK;AACrB;AAEA,SAAgB,aAAa,SAAyC;CACpE,OACE,YAAY,QACZ,OAAO,YAAY,YACnB,kBAAkB,WAClB,QAAQ,iBAAiB;AAE7B;;;;;;AAOA,SAAgB,cAAc,SAA0C;CACtE,IAAI,mBAAmB,aAAa,OAAO;CAC3C,IAAI,YAAY,QAAQ,OAAO,YAAY,UAAU,OAAO;CAC5D,MAAM,EAAE,QAAQ,SAAS;CACzB,OAAO,OAAO,WAAW,YAAY,OAAO,MAAM,OAAO,SAAS;AACpE;AAEA,SAAgB,aACd,OACA,GAC8B;CAC9B,MAAM,YAAY,EAAE,IAAI,WAAW;CACnC,MAAM,cAAc,GAAG,EAAE,IAAI,OAAO,IAAI,EAAE,IAAI;CAC9C,MAAM,UAAU,QAAQ,IAAI,CAAC,CAAC,YAAY;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
|
"name": "@shware/http",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
"@shware/utils": "^1.5.2"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@types/node": "^26.1.
|
|
75
|
-
"@types/react": "^19.2.
|
|
74
|
+
"@types/node": "^26.1.2",
|
|
75
|
+
"@types/react": "^19.2.18",
|
|
76
76
|
"typescript": "^7.0.2",
|
|
77
77
|
"@repo/typescript-config": "0.0.0"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"hono": "^4.12.
|
|
80
|
+
"hono": "^4.12.33",
|
|
81
81
|
"i18next": "^26.3.6",
|
|
82
82
|
"react": "^19.2.8"
|
|
83
83
|
},
|