Pavel Ševčík
4 years ago
No known key found for this signature in database
GPG Key ID: D3B8A90B4072D9DB
1 changed files with
8 additions and
1 deletions
-
lib/http-server/http-server.js
|
|
@ -8,6 +8,7 @@ const fs = require('fs') |
|
|
|
const express = require('express') |
|
|
|
const helmet = require('helmet') |
|
|
|
const Logger = require('../logger') |
|
|
|
const errors = require('../errors'); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -117,12 +118,18 @@ class HttpServer { |
|
|
|
/** |
|
|
|
* Return an error response |
|
|
|
* @param {object} res - http response object |
|
|
|
* @param {object} data - data object |
|
|
|
* @param {string | Error} data - data object |
|
|
|
* @param {number} [errorCode=400] - HTTP status code |
|
|
|
*/ |
|
|
|
static sendError(res, data, errorCode) { |
|
|
|
if (errorCode == null) |
|
|
|
errorCode = 400 |
|
|
|
|
|
|
|
if (data instanceof Error) { |
|
|
|
Logger.error(data, 'API: Unhandled error') |
|
|
|
data = errors.generic.GEN |
|
|
|
} |
|
|
|
|
|
|
|
const ret = { |
|
|
|
status: 'error', |
|
|
|
error: data |
|
|
|