19 lines
441 B
TypeScript
19 lines
441 B
TypeScript
import { ServerError } from "@spec/relay";
|
|
|
|
import type { Level } from "../level.ts";
|
|
import { getTracedAt } from "../stack.ts";
|
|
|
|
export function toServerLog(arg: any, level: Level): any {
|
|
if (arg instanceof ServerError) {
|
|
const obj: any = {
|
|
message: arg.message,
|
|
data: arg.data,
|
|
at: getTracedAt(arg.stack, "/api/domains"),
|
|
};
|
|
if (level === "debug") {
|
|
obj.stack = arg.stack;
|
|
}
|
|
return obj;
|
|
}
|
|
}
|