mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Narrow LoggerArgs types and fix bad revert
This commit is contained in:
parent
2b26b3744b
commit
409af3898b
@ -11,8 +11,7 @@ if (forcedDebug === true) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match `console.log` inputs
|
export type LoggerArgs = (string | number | (() => string) | Record<any, unknown> | Error);
|
||||||
export type LoggerArgs = Parameters<Console["log"]>[0]
|
|
||||||
export type LoggerFunction = (...args: LoggerArgs[]) => void;
|
export type LoggerFunction = (...args: LoggerArgs[]) => void;
|
||||||
|
|
||||||
export interface ILogger {
|
export interface ILogger {
|
||||||
|
@ -132,11 +132,12 @@ export class RenderingMWs {
|
|||||||
): void {
|
): void {
|
||||||
if (err instanceof ErrorDTO) {
|
if (err instanceof ErrorDTO) {
|
||||||
if (err.details) {
|
if (err.details) {
|
||||||
|
const logFn = Logger.logLevelForError(err.code)
|
||||||
LoggerRouter.log(logFn, req, res);
|
LoggerRouter.log(logFn, req, res);
|
||||||
// use separate rendering for detailsStr
|
// use separate rendering for detailsStr
|
||||||
const d = err.detailsStr;
|
const d = err.detailsStr;
|
||||||
delete err.detailsStr;
|
delete err.detailsStr;
|
||||||
console.log(err);
|
logFn(err);
|
||||||
err.detailsStr = d;
|
err.detailsStr = d;
|
||||||
delete err.details; // do not send back error object to the client side
|
delete err.details; // do not send back error object to the client side
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user