wildflock/hooks/log-error.ts

18 lines
383 B
TypeScript

import type { HookContext, NextFunction } from '../declarations'
import { logger } from '../logger'
export const logError = async (context: HookContext, next: NextFunction) => {
try {
await next()
} catch (error: any) {
logger.error(error.stack)
// Log validation errors
if (error.data) {
logger.error('Data: %O', error.data)
}
throw error
}
}