core: fix HTTP exception handling order to prevent NamedError from masking HTTP exceptions

docs: add OPENCODE_PASSWORD environment variable documentation for basic auth
This commit is contained in:
Dax Raad
2026-01-12 15:43:48 -05:00
parent 1954c1255e
commit 7ca767de55
3 changed files with 34 additions and 23 deletions

View File

@@ -83,7 +83,6 @@ export namespace Server {
log.error("failed", {
error: err,
})
if (err instanceof HTTPException) return err.getResponse()
if (err instanceof NamedError) {
let status: ContentfulStatusCode
if (err instanceof Storage.NotFoundError) status = 404
@@ -92,6 +91,7 @@ export namespace Server {
else status = 500
return c.json(err.toObject(), { status })
}
if (err instanceof HTTPException) return err.getResponse()
const message = err instanceof Error && err.stack ? err.stack : err.toString()
return c.json(new NamedError.Unknown({ message }).toObject(), {
status: 500,