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:
parent
1954c1255e
commit
7ca767de55
3 changed files with 34 additions and 23 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue