(error = {})
| 44 | |
| 45 | |
| 46 | function handleError (error = {}) { |
| 47 | // Using duck typing to know if we explicitly threw this error |
| 48 | // If not then wrapping original error into UnexpectedError |
| 49 | if (!error.requestType) { error = new errors.UnexpectedError({ original_error: error }); } |
| 50 | |
| 51 | const { requestType, title, message, resolution } = error; |
| 52 | status = REQUEST_TYPE_STATUS_CODE[requestType], |
| 53 | body = JSON.stringify({ |
| 54 | title, |
| 55 | message, |
| 56 | resolution |
| 57 | }); |
| 58 | |
| 59 | this.set(HEADER_CONTENT_TYPE, 'application/json'); |
| 60 | this.set(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, '*'); |
| 61 | |
| 62 | return this.status(status).send(body); |
| 63 | }; |
| 64 | |
| 65 | app.set('trust proxy', true); |
| 66 |
nothing calls this directly
no outgoing calls
no test coverage detected