eservices-back-core 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/error-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"error-middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/error-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;wCAWV,OAAO,OAAO,QAAQ;AAAtD,wBAgCE"}
|
|
@@ -19,23 +19,30 @@ const use_logger_1 = require("../logger/use-logger");
|
|
|
19
19
|
const auth_error_1 = __importDefault(require("../errors/auth-error"));
|
|
20
20
|
const debug_1 = __importDefault(require("debug"));
|
|
21
21
|
const utils_1 = require("../utils");
|
|
22
|
+
const constants_1 = require("../constants");
|
|
22
23
|
const debug = (0, debug_1.default)((0, utils_1.getCoreDebugMark)("error-handler"));
|
|
23
24
|
exports.default = (err, req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
try {
|
|
26
|
+
debug(err);
|
|
27
|
+
use_logger_1.Logger.error('Error level %o', err);
|
|
28
|
+
// Error bind with Authorization
|
|
29
|
+
if (err instanceof auth_error_1.default || (req.method === "GET" && !req.infoUserId)) {
|
|
30
|
+
debug('Auth error');
|
|
31
|
+
return res.redirect((0, auth_middleware_1.authModule)().endSessionURL());
|
|
32
|
+
}
|
|
33
|
+
if (typeof err === "string")
|
|
34
|
+
return void res.status(400).json((0, error_response_dto_1.default)(err, 400));
|
|
35
|
+
if (err instanceof api_error_1.default)
|
|
36
|
+
return void res
|
|
37
|
+
.status(err.status)
|
|
38
|
+
.json((0, error_response_dto_1.default)(err.message, err.status));
|
|
39
|
+
if (err instanceof Error)
|
|
40
|
+
return void res.status(400).json((0, error_response_dto_1.default)(err.message, 400));
|
|
41
|
+
res.writeHead(302, { location: (0, auth_middleware_1.authModule)().authorizationUrl() });
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
res.status(500);
|
|
45
|
+
res.send(constants_1.DEFAULT_ERROR_MESSAGE);
|
|
30
46
|
}
|
|
31
|
-
if (typeof err === "string")
|
|
32
|
-
return void res.status(400).json((0, error_response_dto_1.default)(err, 400));
|
|
33
|
-
if (err instanceof api_error_1.default)
|
|
34
|
-
return void res
|
|
35
|
-
.status(err.status)
|
|
36
|
-
.json((0, error_response_dto_1.default)(err.message, err.status));
|
|
37
|
-
if (err instanceof Error)
|
|
38
|
-
return void res.status(400).json((0, error_response_dto_1.default)(err.message, 400));
|
|
39
|
-
res.writeHead(302, { location: (0, auth_middleware_1.authModule)().authorizationUrl() });
|
|
40
47
|
});
|
|
41
48
|
//# sourceMappingURL=error-middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-middleware.js","sourceRoot":"","sources":["../../src/middleware/error-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oEAA2C;AAE3C,oFAA0D;AAC1D,uDAA6C;AAC7C,qDAA4C;AAC5C,sEAA6C;AAC7C,kDAA+B;AAC/B,oCAA0C;
|
|
1
|
+
{"version":3,"file":"error-middleware.js","sourceRoot":"","sources":["../../src/middleware/error-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oEAA2C;AAE3C,oFAA0D;AAC1D,uDAA6C;AAC7C,qDAA4C;AAC5C,sEAA6C;AAC7C,kDAA+B;AAC/B,oCAA0C;AAC1C,4CAAmD;AAEnD,MAAM,KAAK,GAAG,IAAA,eAAW,EAAC,IAAA,wBAAgB,EAAC,eAAe,CAAC,CAAC,CAAC;AAE7D,kBAAe,C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