Skip to content

Commit

Permalink
Extrapolated fatal errors into a separate module.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Oct 7, 2013
1 parent 4d2e6c0 commit 604bb54
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/errors/fatal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Fatal Errors
*/


module.exports = function(sails) {

return {

__UnknownPolicy__: function (policy, source) {
source = source || 'config.policies';

sails.log.error('Unknown policy, "' + policy + '", referenced in `' + source + '`.');
sails.log.error('Are you sure that policy exists?');
sails.log.error('It would be located at: `' + sails.config.paths.policies + '/' + policy + '.js`');
return process.exit(1);
},

__InvalidConnection__: function (connection, sourceModelId) {
sails.log.error('Invalid connection/adapter reference (' + connection + ') ' + 'in model (' + sourceModelId +')');
return process.exit(1);
},

__UnknownConnection__: function (connectionId, sourceModelId) {
sails.log.error('Unknown connection, "' + connectionId + '", referenced in model `' + sourceModelId + '`.');
sails.log.error('Are you sure that connection exists? It should be defined in `sails.config.connections`.');

var probableAdapterModuleName = 'sails-' + connectionId.toLowerCase();
sails.log.error('Otherwise, if you\'re trying to use an adapter named `' + connectionId + '`, please run ' +
'`npm install ' + probableAdapterModuleName + '@' + sails.majorVersion + '.' + sails.minorVersion + '.x`');
return process.exit(1);
}
};

};

0 comments on commit 604bb54

Please sign in to comment.