mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 09:26:47 +00:00
print requestError logs in backend when in dev mode
This commit is contained in:
@@ -4,10 +4,17 @@ import * as Sentry from '@sentry/node';
|
|||||||
import { InternalServerError } from "../utils/errors";
|
import { InternalServerError } from "../utils/errors";
|
||||||
import { getLogger } from "../utils/logger";
|
import { getLogger } from "../utils/logger";
|
||||||
import RequestError, { LogLevel } from "../utils/requestError";
|
import RequestError, { LogLevel } from "../utils/requestError";
|
||||||
|
import { NODE_ENV } from "../config";
|
||||||
|
|
||||||
|
|
||||||
export const requestErrorHandler: ErrorRequestHandler = (error: RequestError | Error, req, res, next) => {
|
export const requestErrorHandler: ErrorRequestHandler = (error: RequestError | Error, req, res, next) => {
|
||||||
if (res.headersSent) return next();
|
if (res.headersSent) return next();
|
||||||
|
if (NODE_ENV !== "production" && error instanceof RequestError) {
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
console.log(error)
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Find better way to type check for error. In current setting you need to cast type to get the functions and variables from RequestError
|
//TODO: Find better way to type check for error. In current setting you need to cast type to get the functions and variables from RequestError
|
||||||
if (!(error instanceof RequestError)) {
|
if (!(error instanceof RequestError)) {
|
||||||
error = InternalServerError({ context: { exception: error.message }, stack: error.stack })
|
error = InternalServerError({ context: { exception: error.message }, stack: error.stack })
|
||||||
|
|||||||
Reference in New Issue
Block a user