Skip to content

Commit

Permalink
馃帹 remove circular dependency solution in errors/index.js
Browse files Browse the repository at this point in the history
refs #6982
[ci skip]
  • Loading branch information
kirrg001 authored and ErisDS committed Sep 20, 2016
1 parent 34e48dc commit 1f85604
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions core/server/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,12 @@ var _ = require('lodash'),
DatabaseNotPopulated = require('./database-not-populated'),
DatabaseVersion = require('./database-version'),
i18n = require('../i18n'),
config,
config = require('../config'),
errors,

// Paths for views
userErrorTemplateExists = false;

// Shim right now to deal with circular dependencies.
// @TODO(hswolff): remove circular dependency and lazy require.
function getConfigModule() {
if (!config) {
config = require('../config');
}

return config;
}

function isValidErrorStatus(status) {
return _.isNumber(status) && status >= 400 && status < 600;
}
Expand Down Expand Up @@ -69,7 +59,7 @@ function getStatusCode(error) {
*/
errors = {
updateActiveTheme: function (activeTheme) {
userErrorTemplateExists = getConfigModule().get('paths').availableThemes[activeTheme].hasOwnProperty('error.hbs');
userErrorTemplateExists = config.get('paths').availableThemes[activeTheme].hasOwnProperty('error.hbs');
},

throwError: function (err) {
Expand Down Expand Up @@ -295,7 +285,7 @@ errors = {
renderErrorPage: function (statusCode, err, req, res, next) {
/*jshint unused:false*/
var self = this,
defaultErrorTemplatePath = path.resolve(getConfigModule().get('paths').adminViews, 'user-error.hbs');
defaultErrorTemplatePath = path.resolve(config.get('paths').adminViews, 'user-error.hbs');

function parseStack(stack) {
if (!_.isString(stack)) {
Expand Down

0 comments on commit 1f85604

Please sign in to comment.