mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 17:56:34 +00:00
fix: onError uses init obs when request trace missing
If event.context.obs not set, fall back to init-level obs and flag no request trace in error message. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
925d9fd6dc
commit
85f8456cf0
2 changed files with 18 additions and 2 deletions
|
|
@ -208,9 +208,17 @@ export class Plugin extends BSBService<InstanceType<typeof Config>, typeof Event
|
||||||
event.context.obs = reqObs;
|
event.context.obs = reqObs;
|
||||||
},
|
},
|
||||||
onError: (error, event) => {
|
onError: (error, event) => {
|
||||||
const reqObs = event.context.obs ?? obs;
|
const reqObs = event.context.obs;
|
||||||
const status = error.status ?? 500;
|
const status = error.status ?? 500;
|
||||||
const path = event.req.url ?? "unknown";
|
const path = event.req.url ?? "unknown";
|
||||||
|
if (!reqObs) {
|
||||||
|
obs.log.error("HTTP {status} {path}: {err} (no request trace)", {
|
||||||
|
status,
|
||||||
|
path,
|
||||||
|
err: error.message ?? String(error),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (status >= 500) {
|
if (status >= 500) {
|
||||||
reqObs.log.error("HTTP {status} {path}: {err}", {
|
reqObs.log.error("HTTP {status} {path}: {err}", {
|
||||||
status,
|
status,
|
||||||
|
|
|
||||||
|
|
@ -177,9 +177,17 @@ export class Plugin extends BSBService<InstanceType<typeof Config>, typeof Event
|
||||||
event.context.obs = reqObs;
|
event.context.obs = reqObs;
|
||||||
},
|
},
|
||||||
onError: (error, event) => {
|
onError: (error, event) => {
|
||||||
const reqObs = event.context.obs ?? obs;
|
const reqObs = event.context.obs;
|
||||||
const status = error.status ?? 500;
|
const status = error.status ?? 500;
|
||||||
const path = event.req.url ?? "unknown";
|
const path = event.req.url ?? "unknown";
|
||||||
|
if (!reqObs) {
|
||||||
|
obs.log.error("HTTP {status} {path}: {err} (no request trace)", {
|
||||||
|
status,
|
||||||
|
path,
|
||||||
|
err: error.message ?? String(error),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (status >= 500) {
|
if (status >= 500) {
|
||||||
reqObs.log.error("HTTP {status} {path}: {err}", {
|
reqObs.log.error("HTTP {status} {path}: {err}", {
|
||||||
status,
|
status,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue