UNPKG

1 kBJavaScriptView 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 });
7exports.createUnexpectedHttpErrorLogger = void 0;
8/**
9 * Creates a Logger that logs an Error if the HTTP status code is not expected
10 *
11 * @param expectedStatusCode - HTTP status code that is expected
12 */
13function createUnexpectedHttpErrorLogger(expectedStatusCode) {
14 return function logUnexpectedHttpError(err, statusCode, req) {
15 var _a;
16 if (statusCode === expectedStatusCode)
17 return;
18 /* istanbul ignore next */
19 console.error('Unhandled error in %s %s: %s %s', req.method, req.url, statusCode, (_a = err.stack) !== null && _a !== void 0 ? _a : err);
20 };
21}
22exports.createUnexpectedHttpErrorLogger = createUnexpectedHttpErrorLogger;
23//# sourceMappingURL=http-error-logger.js.map
\No newline at end of file