Files
archived-gitea-ai-assistant/src/utils/error-log.ts
jeffusion 22b603258a fix(repo): add structured diagnostics for repository list failures
Capture request/runtime context plus nested error metadata so docker-only repository-list issues can be diagnosed quickly.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
2026-03-26 23:50:59 +08:00

31 lines
707 B
TypeScript

type UnknownRecord = Record<string, unknown>;
function toUnknownRecord(value: unknown): UnknownRecord {
if (typeof value === 'object' && value !== null) {
return value as UnknownRecord;
}
return { value };
}
export function toErrorLogMeta(error: unknown): UnknownRecord {
if (error instanceof Error) {
const base: UnknownRecord = {
name: error.name,
message: error.message,
stack: error.stack,
};
const ownProps = Object.getOwnPropertyNames(error);
for (const prop of ownProps) {
if (prop in base) {
continue;
}
base[prop] = (error as unknown as UnknownRecord)[prop];
}
return base;
}
return toUnknownRecord(error);
}