UNPKG

1.14 kBJavaScriptView Raw
1import { __extends, __read } from "tslib";
2var ServiceException = (function (_super) {
3 __extends(ServiceException, _super);
4 function ServiceException(options) {
5 var _this = _super.call(this, options.message) || this;
6 Object.setPrototypeOf(_this, ServiceException.prototype);
7 _this.name = options.name;
8 _this.$fault = options.$fault;
9 _this.$metadata = options.$metadata;
10 return _this;
11 }
12 return ServiceException;
13}(Error));
14export { ServiceException };
15export var decorateServiceException = function (exception, additions) {
16 if (additions === void 0) { additions = {}; }
17 Object.entries(additions)
18 .filter(function (_a) {
19 var _b = __read(_a, 2), v = _b[1];
20 return v !== undefined;
21 })
22 .forEach(function (_a) {
23 var _b = __read(_a, 2), k = _b[0], v = _b[1];
24 if (exception[k] == undefined || exception[k] === "") {
25 exception[k] = v;
26 }
27 });
28 var message = exception.message || exception.Message || "UnknownError";
29 exception.message = message;
30 delete exception.Message;
31 return exception;
32};