1 | import { global } from "../utilities/globals/index.js";
|
2 | import { ApolloErrorMessageHandler } from "../utilities/globals/invariantWrappers.js";
|
3 | import { setErrorMessageHandler } from "./setErrorMessageHandler.js";
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export function loadErrorMessageHandler() {
|
9 | var errorCodes = [];
|
10 | for (var _i = 0; _i < arguments.length; _i++) {
|
11 | errorCodes[_i] = arguments[_i];
|
12 | }
|
13 | setErrorMessageHandler(handler);
|
14 | for (var _a = 0, errorCodes_1 = errorCodes; _a < errorCodes_1.length; _a++) {
|
15 | var codes = errorCodes_1[_a];
|
16 | Object.assign(handler, codes);
|
17 | }
|
18 | return handler;
|
19 | }
|
20 | var handler = (function (message, args) {
|
21 | if (typeof message === "number") {
|
22 | var definition = global[ApolloErrorMessageHandler][message];
|
23 | if (!message || !(definition === null || definition === void 0 ? void 0 : definition.message))
|
24 | return;
|
25 | message = definition.message;
|
26 | }
|
27 | return args.reduce(function (msg, arg) { return msg.replace(/%[sdfo]/, String(arg)); }, String(message));
|
28 | });
|
29 |
|
\ | No newline at end of file |