Files
30-seconds-of-code/node_modules/relay-runtime/lib/RelayError.js
2019-08-20 15:52:05 +02:00

47 lines
1.3 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
var _toConsumableArray2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/toConsumableArray"));
/**
* @internal
*
* Factory methods for constructing errors in Relay.
*/
var RelayError = {
create: function create(name, format) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return createError('mustfix', name, format, args);
},
createWarning: function createWarning(name, format) {
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
return createError('warn', name, format, args);
}
};
/**
* @private
*/
function createError(type, name, format, args) {
var error = new Error(require("fbjs/lib/sprintf").apply(void 0, [format].concat((0, _toConsumableArray2["default"])(args))));
error.name = name;
error.type = type;
error.framesToPop = 2;
return error;
}
module.exports = RelayError;