mirror of
https://github.com/jeffusion/gitea-ai-assistant.git
synced 2026-03-27 10:05:50 +00:00
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)
31 lines
707 B
TypeScript
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);
|
|
}
|