UNPKG

graphile-build

Version:

Build a GraphQL schema from plugins

29 lines (28 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = swallowError; var _debug = _interopRequireDefault(require("debug")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const debugWarn = (0, _debug.default)("graphile-build:warn"); function swallowError(e) { // BE VERY CAREFUL NOT TO THROW! // XXX: Improve this if (debugWarn.enabled) { // eslint-disable-next-line no-console console.warn(`Recoverable error occurred:`); debugWarn(e); } else { const errorSnippet = e && typeof e.toString === "function" ? String(e).replace(/\n.*/g, "").slice(0, 320).trim() : null; if (errorSnippet) { // eslint-disable-next-line no-console console.warn(`Recoverable error occurred; use envvar 'DEBUG="graphile-build:warn"' for full error (see: https://graphile.org/postgraphile/debugging )\n> ${errorSnippet}…`); } else { // eslint-disable-next-line no-console console.warn(`Recoverable error occurred; use envvar 'DEBUG="graphile-build:warn"' for error (see: https://graphile.org/postgraphile/debugging )`); } debugWarn(e); } } //# sourceMappingURL=swallowError.js.map