UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

78 lines (73 loc) • 2.5 kB
/** * DevExtreme (esm/__internal/core/utils/error.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { extend } from "../../../core/utils/extend"; import { format } from "../../../core/utils/string"; import { version } from "../../../core/version"; import consoleUtils from "./m_console"; const ERROR_URL = `https://js.devexpress.com/error/${version.split(".").slice(0,2).join("_")}/`; function error(baseErrors, errors) { function getErrorUrl(id) { return ERROR_URL + id } function formatDetails(id, args) { const formatArgs = [exports.ERROR_MESSAGES[id], ...args]; return format.apply(this, formatArgs).replace(/\.*\s*?$/, "") } function formatMessage(id, details) { const kind = null !== id && void 0 !== id && id.startsWith("W") ? "warning" : "error"; return format.apply(this, ["{0} - {1}.\n\nFor additional information on this {2} message, see: {3}", id, details, kind, getErrorUrl(id)]) } function makeError(_ref2) { let [id, ...args] = _ref2; const details = formatDetails(id, args); const url = getErrorUrl(id); const message = formatMessage(id, details); return extend(new Error(message), { __id: id, __details: details, url: url }) } const exports = { ERROR_MESSAGES: extend(errors, baseErrors), Error: function() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key] } return makeError(args) }, log() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2] } const [id] = args; let method = "log"; if (/^E\d+$/.test(id)) { method = "error" } else if (/^W\d+$/.test(id)) { method = "warn" } consoleUtils.logger[method]("log" === method ? id : function(_ref) { let [id, ...details] = _ref; return formatMessage(id, formatDetails(id, details)) }(args)) } }; return exports } export { error }; export default error;