Skip to content

Commit 215a71c

Browse files
authored
feat: add error forwarding support in hono middleware and update tests accordingly
1 parent ba17cf0 commit 215a71c

2 files changed

Lines changed: 189 additions & 184 deletions

File tree

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,12 @@ function honoWrapper(compiler, options) {
662662
},
663663
);
664664
} catch (err) {
665+
if (options?.forwardError) {
666+
await next();
667+
668+
// need the return for prevent to execute the code below and override the status and body set by user in the next middleware
669+
return;
670+
}
665671
context.status(500);
666672

667673
return context.json({ message: /** @type {Error} */ (err).message });

0 commit comments

Comments
 (0)