Respond to Adri's feedback.
This commit is contained in:
parent
aedad69a47
commit
0d2e6d6f5a
|
@ -146,8 +146,8 @@ function applyRoutes(
|
|||
addMiddleware(endpoints.read, mapperMiddleware, { output: true })
|
||||
addMiddleware(endpoints.write, mapperMiddleware, { output: true })
|
||||
if (env.isTest()) {
|
||||
addMiddleware(endpoints.read, testErrorHandling)
|
||||
addMiddleware(endpoints.write, testErrorHandling)
|
||||
addMiddleware(endpoints.read, testErrorHandling())
|
||||
addMiddleware(endpoints.write, testErrorHandling())
|
||||
}
|
||||
addToRouter(endpoints.read)
|
||||
addToRouter(endpoints.write)
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { Ctx } from "@budibase/types"
|
||||
import environment from "../../../../environment"
|
||||
|
||||
export default async (ctx: Ctx, next: any) => {
|
||||
export default () => {
|
||||
if (!environment.isTest()) {
|
||||
throw new Error("This middleware is only for testing")
|
||||
}
|
||||
|
||||
return async (ctx: Ctx, next: any) => {
|
||||
try {
|
||||
await next()
|
||||
} catch (err: any) {
|
||||
if (
|
||||
!(environment.isTest() && ctx.headers["x-budibase-include-stacktrace"])
|
||||
) {
|
||||
if (!ctx.headers["x-budibase-include-stacktrace"]) {
|
||||
throw err
|
||||
}
|
||||
|
||||
|
@ -21,4 +24,5 @@ export default async (ctx: Ctx, next: any) => {
|
|||
ctx.status = status
|
||||
ctx.body = { status, message: error.message, stack: error.stack }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue