'use strict'; // ////////////////////////////////////////////////////////////////////////////// // / DISCLAIMER // / // / Copyright 2013-2014 triAGENS GmbH, Cologne, Germany // / Copyright 2015-2016 ArangoDB GmbH, Cologne, Germany // / // / Licensed under the Apache License, Version 2.0 (the "License") // / you may not use this file except in compliance with the License. // / You may obtain a copy of the License at // / // / http://www.apache.org/licenses/LICENSE-2.0 // / // / Unless required by applicable law or agreed to in writing, software // / distributed under the License is distributed on an "AS IS" BASIS, // / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // / See the License for the specific language governing permissions and // / limitations under the License. // / // / Copyright holder is ArangoDB GmbH, Cologne, Germany // / // / @author Dr. Frank Celler // / @author Alan Plum // ////////////////////////////////////////////////////////////////////////////// const _ = require('lodash'); const fs = require('fs'); const ansiHtml = require('ansi-html'); const dd = require('@arangodb/util').dedent; const arangodb = require('@arangodb'); const actions = require('@arangodb/actions'); const routeLegacyService = require('@arangodb/foxx/legacy/routing').routeService; const codeFrame = require('@arangodb/util').codeFrame; function solarize (ansiText) { try { ansiHtml.setColors({ reset: ['657b83', 'fdf6e3'], black: 'eee8d5', red: 'dc322f', green: '859900', yellow: 'b58900', blue: '268bd2', magenta: 'd33682', cyan: '2aa198', lightgrey: '586e75', darkgrey: '93a1a1' }); const html = ansiHtml(ansiText); return html; } finally { ansiHtml.reset(); } } function escapeHtml (raw) { return String(raw) .replace(/&/g, '&') .replace(/
This service requires configuration and has either not yet been fully configured or is missing some of its dependencies.
`); } // ////////////////////////////////////////////////////////////////////////////// // / @brief routes this service if the original is broken service // ////////////////////////////////////////////////////////////////////////////// function createBrokenServiceRoute (service, err) { if (service.isDevelopment) { const title = String(err).replace(/\n/g, ' '); const frame = codeFrame(err.cause || err, service.basePath, true); let stacktrace = err.stack; while (err.cause) { err = err.cause; stacktrace += `\nvia ${err.stack}`; } const body = [ dd`
An error occurred while mounting this service.
This usually indicates a problem with the service itself.
${solarize(escapeHtml(frame))}` : '', dd`
${escapeHtml(stacktrace)}` ].filter(Boolean).join('\n'); return createErrorRoute(service, body, title); } return createErrorRoute(service, dd`
An error occured while mounting the service.
Please check the log file for errors.