Skip to content

Commit a2b065b

Browse files
committed
fix: only log server errors
1 parent b5b6bd0 commit a2b065b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/core/framework/src/http/middlewares/error-handler.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { ErrorRequestHandler, NextFunction, Response } from "express"
12
import { fromZodIssue } from "zod-validation-error"
2-
import { NextFunction, ErrorRequestHandler, Response } from "express"
33

44
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
5-
import { formatException } from "./exception-formatter"
65
import { MedusaRequest } from "../types"
6+
import { formatException } from "./exception-formatter"
77

88
const QUERY_RUNNER_RELEASED = "QueryRunnerAlreadyReleasedError"
99
const TRANSACTION_STARTED = "TransactionAlreadyStartedError"
@@ -31,7 +31,6 @@ export function errorHandler() {
3131
}
3232

3333
err = formatException(err)
34-
logger.error(err)
3534

3635
const errorType = err.type || err.name
3736
const errObj = {
@@ -82,6 +81,10 @@ export function errorHandler() {
8281
break
8382
}
8483

84+
if (statusCode >= 500) {
85+
logger.error(err)
86+
}
87+
8588
if ("issues" in err && Array.isArray(err.issues)) {
8689
const messages = err.issues.map((issue) => fromZodIssue(issue).toString())
8790
res.status(statusCode).json({

0 commit comments

Comments
 (0)