fix: only log server errors
This commit is contained in:
1 file changed
+6
-3
@@ -1,9 +1,9 @@
|
|||||||
|
import { ErrorRequestHandler, NextFunction, Response } from "express"
|
||||||
import { fromZodIssue } from "zod-validation-error"
|
import { fromZodIssue } from "zod-validation-error"
|
||||||
import { NextFunction, ErrorRequestHandler, Response } from "express"
|
|
||||||
|
|
||||||
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
|
||||||
import { formatException } from "./exception-formatter"
|
|
||||||
import { MedusaRequest } from "../types"
|
import { MedusaRequest } from "../types"
|
||||||
|
import { formatException } from "./exception-formatter"
|
||||||
|
|
||||||
const QUERY_RUNNER_RELEASED = "QueryRunnerAlreadyReleasedError"
|
const QUERY_RUNNER_RELEASED = "QueryRunnerAlreadyReleasedError"
|
||||||
const TRANSACTION_STARTED = "TransactionAlreadyStartedError"
|
const TRANSACTION_STARTED = "TransactionAlreadyStartedError"
|
||||||
@@ -31,7 +31,6 @@ export function errorHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = formatException(err)
|
err = formatException(err)
|
||||||
logger.error(err)
|
|
||||||
|
|
||||||
const errorType = err.type || err.name
|
const errorType = err.type || err.name
|
||||||
const errObj = {
|
const errObj = {
|
||||||
@@ -82,6 +81,10 @@ export function errorHandler() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statusCode >= 500) {
|
||||||
|
logger.error(err)
|
||||||
|
}
|
||||||
|
|
||||||
if ("issues" in err && Array.isArray(err.issues)) {
|
if ("issues" in err && Array.isArray(err.issues)) {
|
||||||
const messages = err.issues.map((issue) => fromZodIssue(issue).toString())
|
const messages = err.issues.map((issue) => fromZodIssue(issue).toString())
|
||||||
res.status(statusCode).json({
|
res.status(statusCode).json({
|
||||||
|
|||||||
Reference in new issue
Block a user