Skip to content

Commit

Permalink
fix: Private name "#errorHandler" must be declared in an enclosing class
Browse files Browse the repository at this point in the history
  • Loading branch information
TiBianMod committed Nov 14, 2024
1 parent 082862b commit c02565d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hono-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
#notFoundHandler: NotFoundHandler = notFoundHandler
#errorHandler: ErrorHandler = errorHandler

get errorHandler() {
return this.#errorHandler
}

/**
* `.route()` allows grouping other Hono instance in routes.
*
Expand Down Expand Up @@ -214,11 +218,11 @@ class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string =
const subApp = this.basePath(path)
app.routes.map((r) => {
let handler
if (app.#errorHandler === errorHandler) {
if (app.errorHandler === errorHandler) {
handler = r.handler
} else {
handler = async (c: Context, next: Next) =>
(await compose<Context>([], app.#errorHandler)(c, () => r.handler(c, next))).res
(await compose<Context>([], app.errorHandler)(c, () => r.handler(c, next))).res
;(handler as any)[COMPOSED_HANDLER] = r.handler
}

Expand Down

0 comments on commit c02565d

Please sign in to comment.