hono 2.2.4 → 2.2.5

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.
@@ -48,11 +48,20 @@ const compose = (middleware, onNotFound, onError) => {
48
48
  return context;
49
49
  }
50
50
  else {
51
- return res.then((res) => {
51
+ return res
52
+ .then((res) => {
52
53
  if (res && context.finalized === false) {
53
54
  context.res = res;
54
55
  }
55
56
  return context;
57
+ })
58
+ .catch((err) => {
59
+ if (err instanceof Error && context instanceof context_1.HonoContext && onError) {
60
+ context.error = err;
61
+ context.res = onError(err, context);
62
+ return context;
63
+ }
64
+ throw err;
56
65
  });
57
66
  }
58
67
  }
package/dist/compose.js CHANGED
@@ -45,11 +45,20 @@ export const compose = (middleware, onNotFound, onError) => {
45
45
  return context;
46
46
  }
47
47
  else {
48
- return res.then((res) => {
48
+ return res
49
+ .then((res) => {
49
50
  if (res && context.finalized === false) {
50
51
  context.res = res;
51
52
  }
52
53
  return context;
54
+ })
55
+ .catch((err) => {
56
+ if (err instanceof Error && context instanceof HonoContext && onError) {
57
+ context.error = err;
58
+ context.res = onError(err, context);
59
+ return context;
60
+ }
61
+ throw err;
53
62
  });
54
63
  }
55
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "Ultrafast web framework for Cloudflare Workers.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",