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