File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
packages/core/framework/src/http Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ import express from "express"
9
9
import querystring from "querystring"
10
10
import supertest from "supertest"
11
11
12
- import { config } from "../mocks"
13
12
import { MedusaContainer } from "@medusajs/types"
14
13
import { configManager } from "../../../config"
15
14
import { container } from "../../../container"
16
15
import { featureFlagsLoader } from "../../../feature-flags"
17
16
import { logger } from "../../../logger"
18
- import { MedusaRequest } from "../../types"
19
17
import { ApiLoader } from "../../router"
18
+ import { MedusaRequest } from "../../types"
19
+ import { config } from "../mocks"
20
20
21
21
function asArray ( resolvers ) {
22
22
return {
@@ -69,6 +69,7 @@ export const createServer = async (rootDir) => {
69
69
container . register ( {
70
70
logger : asValue ( {
71
71
error : ( ) => { } ,
72
+ info : ( ) => { } ,
72
73
} ) ,
73
74
manager : asValue ( { } ) ,
74
75
} )
Original file line number Diff line number Diff line change
1
+ import { ErrorRequestHandler , NextFunction , Response } from "express"
1
2
import { fromZodIssue } from "zod-validation-error"
2
- import { NextFunction , ErrorRequestHandler , Response } from "express"
3
3
4
4
import { ContainerRegistrationKeys , MedusaError } from "@medusajs/utils"
5
- import { formatException } from "./exception-formatter"
6
5
import { MedusaRequest } from "../types"
6
+ import { formatException } from "./exception-formatter"
7
7
8
8
const QUERY_RUNNER_RELEASED = "QueryRunnerAlreadyReleasedError"
9
9
const TRANSACTION_STARTED = "TransactionAlreadyStartedError"
@@ -31,7 +31,6 @@ export function errorHandler() {
31
31
}
32
32
33
33
err = formatException ( err )
34
- logger . error ( err )
35
34
36
35
const errorType = err . type || err . name
37
36
const errObj = {
@@ -82,6 +81,12 @@ export function errorHandler() {
82
81
break
83
82
}
84
83
84
+ if ( statusCode >= 500 ) {
85
+ logger . error ( err )
86
+ } else {
87
+ logger . info ( err . message )
88
+ }
89
+
85
90
if ( "issues" in err && Array . isArray ( err . issues ) ) {
86
91
const messages = err . issues . map ( ( issue ) => fromZodIssue ( issue ) . toString ( ) )
87
92
res . status ( statusCode ) . json ( {
You can’t perform that action at this time.
0 commit comments