data-mapping
Version:
Mapping the response to the defined data type.
45 lines (44 loc) • 1.77 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var mapping_utils_1 = require("./mapping.utils");
exports.ErrorConstant = {
UNKNOWN: 'An unknown error has occurred when mapping data.',
NULL: 'The data provided is null.',
NOT_ARRAY: 'The data provided is not an array.',
PROVIDER_MAPPER: 'Please provide data mapper to parse data.',
IGNORED: 'The result has been ignored.'
};
var MappingError = /** @class */ (function (_super) {
__extends(MappingError, _super);
function MappingError(message, code, data) {
var _this = this;
var messages;
if (message instanceof Array) {
messages = message;
message = message[0];
}
if (mapping_utils_1.isBlank(message))
message = exports.ErrorConstant.UNKNOWN;
_this = _super.call(this, message) || this;
if (mapping_utils_1.isNotBlank(messages))
_this.messages = messages;
_this.code = code != null ? code : 1;
_this.data = data;
return _this;
}
return MappingError;
}(Error));
exports.MappingError = MappingError;
;