Only show stack traces if you ask for them.
This commit is contained in:
parent
4a2f688456
commit
6b306266b5
|
@ -15,21 +15,19 @@ export async function errorHandling(ctx: any, next: any) {
|
|||
console.error(err)
|
||||
}
|
||||
|
||||
if (environment.isTest()) {
|
||||
ctx.body = {
|
||||
message: err.message,
|
||||
status: status,
|
||||
error: errors.getPublicError(err),
|
||||
stack: err.stack,
|
||||
}
|
||||
} else {
|
||||
ctx.body = {
|
||||
message: err.message,
|
||||
status: status,
|
||||
validationErrors: err.validation,
|
||||
error: errors.getPublicError(err),
|
||||
}
|
||||
let error: APIError = {
|
||||
message: err.message,
|
||||
status: status,
|
||||
validationErrors: err.validation,
|
||||
error: errors.getPublicError(err),
|
||||
}
|
||||
|
||||
if (environment.isTest() && ctx.headers["x-budibase-include-stacktrace"]) {
|
||||
// @ts-ignore
|
||||
error.stack = err.stack
|
||||
}
|
||||
|
||||
ctx.body = error
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,11 @@ export abstract class TestAPI {
|
|||
url += `?${queryParams.join("&")}`
|
||||
}
|
||||
|
||||
let request = this.request[method](url).set(this.config.defaultHeaders())
|
||||
let request = this.request[method](url).set(
|
||||
this.config.defaultHeaders({
|
||||
"x-budibase-include-stacktrace": "true",
|
||||
})
|
||||
)
|
||||
if (headers) {
|
||||
request = request.set(headers)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue