more fixes to Mastodon logging

This commit is contained in:
Hazelnoot 2025-05-06 21:06:33 -04:00
parent b6f4fda80d
commit 9db39d449f
2 changed files with 8 additions and 19 deletions

View file

@ -14,10 +14,6 @@ import { getBaseUrl } from '@/server/api/mastodon/MastodonClientService.js';
export class MastodonLogger {
public readonly logger: Logger;
public get verbose() {
return this.logger.verbose;
}
constructor(
loggerService: LoggerService,
) {
@ -65,13 +61,12 @@ export function getErrorException(error: unknown): Error | null {
return error.cause;
}
// Horrible hack to "recreate" the error without calling a constructor (since we want to re-use the stack).
return Object.assign(Object.create(Error), {
name: error.name,
stack: error.stack,
message: error.message,
cause: error.cause,
});
const ex = new Error();
ex.name = error.name;
ex.stack = error.stack;
ex.message = error.message;
ex.cause = error.cause;
return ex;
}
}
@ -142,13 +137,6 @@ function unpackAxiosError(error: unknown): unknown {
return error.cause;
}
if ('code' in error) {
return {
code: error.code,
message: String(error),
};
}
// No data - this is a fallback to avoid leaking request/response details in the error
return String(error);
}