@okay-e9g/hono-config 0.0.17 → 0.0.19

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Shared Hono config for Okay Engineering",
4
4
  "devDependencies": {
5
5
  "@hono/zod-openapi": "1.5.1",
6
- "hono": "4.12.31",
6
+ "hono": "4.12.32",
7
7
  "pino": "10.3.1",
8
8
  "pino-pretty": "13.1.3",
9
9
  "superjson": "2.2.6",
@@ -22,7 +22,7 @@
22
22
  "name": "@okay-e9g/hono-config",
23
23
  "peerDependencies": {
24
24
  "@hono/zod-openapi": "^1.5.1",
25
- "hono": "^4.12.31",
25
+ "hono": "^4.12.32",
26
26
  "pino": "^10.3.1",
27
27
  "pino-pretty": "^13.1.3",
28
28
  "superjson": "^2.2.6",
@@ -48,5 +48,5 @@
48
48
  "prepublishOnly": "bun run typecheck && bun test",
49
49
  "typecheck": "tsc --noEmit"
50
50
  },
51
- "version": "0.0.17"
51
+ "version": "0.0.19"
52
52
  }
@@ -10,7 +10,7 @@ import type { ResponseEnv } from '../middlewares/ensure-rt';
10
10
  import { type ClientErrorStatusCode, rpcStandardErrorText, type ServerErrorStatusCode } from '../schemas';
11
11
 
12
12
  interface TypedHTTPException extends Omit<HTTPException, 'status'> {
13
- status: ClientErrorStatusCode & ServerErrorStatusCode;
13
+ status: ClientErrorStatusCode | ServerErrorStatusCode;
14
14
  }
15
15
 
16
16
  const assertHTTPException = (err: Error): err is TypedHTTPException => {
@@ -23,8 +23,9 @@ const assertHTTPException = (err: Error): err is TypedHTTPException => {
23
23
  * Errors are rethrown when no response helper has been installed, allowing
24
24
  * Hono's fallback error handling to handle apps that are not using this
25
25
  * package's response envelopes. API helpers preserve HTTP error semantics.
26
- * RPC helpers map validation failures to `Invalid Params` and all other
27
- * failures to `Internal Error`, returning a JSON-RPC envelope with a `null` id.
26
+ * RPC helpers map validation failures to `Invalid Params`, 4xx HTTP exceptions
27
+ * to `Invalid Request`, and 5xx or generic failures to `Internal Error`,
28
+ * returning a JSON-RPC envelope with a `null` id.
28
29
  *
29
30
  * @internal
30
31
  */
@@ -57,12 +58,9 @@ export const onError = <T extends Env>(): ErrorHandler<T> => {
57
58
  return c.json(response.error(status, message), status);
58
59
  }
59
60
 
60
- return c.json(
61
- response.error({
62
- code: -32603,
63
- message: message === '' ? rpcStandardErrorText['-32603'] : message,
64
- }),
65
- );
61
+ const code = status < 500 ? -32600 : -32603;
62
+
63
+ return c.json(response.error({ code, message: message === '' ? rpcStandardErrorText[code] : message }));
66
64
  }
67
65
 
68
66
  const errMessage = err instanceof Error ? err.message : err;