Only show stack traces if you ask for them.

This commit is contained in:
Sam Rose 2024-02-29 11:09:39 +00:00
parent 4a2f688456
commit 6b306266b5
No known key found for this signature in database
2 changed files with 17 additions and 15 deletions

View File

@ -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
}
}

View File

@ -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)
}