"use strict";
/**
 * Uniform error handling for Liza: error chaining
 *
 *  Copyright (C) 2010-2019 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.chain = exports.isChained = void 0;
/**
 * Type predicate for `ChainedError`
 *
 * This predicate can be used at runtime to determine whether an error is
 * chained.
 *
 * @param e error object
 *
 * @return whether `e` is of type ChainedError
 */
exports.isChained = function (e) {
    return e.chain !== undefined;
};
/**
 * Chains two `Error`s
 *
 * This is intended to be used as if it were a constructor, where the first
 * argument is a new `Error` instance.
 *
 * @param enew  new error
 * @param eprev error to chain
 *
 * @return `enew` with `eprev` chained
 */
function chain(enew, eprev) {
    enew.chain = eprev;
    return enew;
}
exports.chain = chain;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2hhaW5lZEVycm9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiQ2hhaW5lZEVycm9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQW1CRzs7O0FBcUJIOzs7Ozs7Ozs7R0FTRztBQUNVLFFBQUEsU0FBUyxHQUFHLFVBQUMsQ0FBUTtJQUNoQyxPQUFlLENBQUUsQ0FBQyxLQUFLLEtBQUssU0FBUztBQUFyQyxDQUFxQyxDQUFDO0FBRXhDOzs7Ozs7Ozs7O0dBVUc7QUFDSCxTQUFnQixLQUFLLENBQUMsSUFBVyxFQUFFLEtBQVk7SUFDakIsSUFBSyxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7SUFDaEQsT0FBcUIsSUFBSSxDQUFDO0FBQzVCLENBQUM7QUFIRCxzQkFHQyJ9