UNPKG

899 BJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. 2019. All Rights Reserved.
3// Node module: @loopback/testlab
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7/**
8 * Creates a Logger that logs an Error if the HTTP status code is not expected
9 *
10 * @param expectedStatusCode - HTTP status code that is expected
11 */
12function createUnexpectedHttpErrorLogger(expectedStatusCode) {
13 return function logUnexpectedHttpError(err, statusCode, req) {
14 if (statusCode === expectedStatusCode)
15 return;
16 /* istanbul ignore next */
17 console.error('Unhandled error in %s %s: %s %s', req.method, req.url, statusCode, err.stack || err);
18 };
19}
20exports.createUnexpectedHttpErrorLogger = createUnexpectedHttpErrorLogger;
21//# sourceMappingURL=http-error-logger.js.map
\No newline at end of file