Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function(transaction, error) {
debug.error("error: ", error);
if(transaction && !transaction.error) {
try {
transaction.abort();
} catch(e) {
// Transaction has is already completed or aborted, this is probably a programming error
debug.warn("attempt to abort and already completed or aborted transaction");
}
}
if(callback && "function" === typeof callback) {
callback.call(undefined, error);
}
}
}
} else {
/** The translation package path
* @type {string} */
// NOTE: We load the translation only here because the launcher will have
// to load it by itself (translations are not synchronous between
// main and child processes)
let tr_path = fs.makeAbsolute('translations/' + translate.language + '.ntp');
// If the translation was not loaded and a package exists for this language...
if(!translate.loaded(tr_path) && fs.fileExists(tr_path) === true) {
// Load the translation package
error = translate.load(translate.language, tr_path);
// If an error occured
if(e(error))
// Make it fatal
debug.error(`Failed to load the translation package for "${translate.language}"`, error);
}
/** The dolphin's explorer file
* @type {string|NightError} */
let content = fs.readFile('explorer.js');
// If the reading failed...
if(e(content))
// Make it fatal
debug.error(tr('Failed to load the explorer script'), content);
// Run the explorer file
eval(content);
}
// Load the translation package
error = translate.load(translate.language, tr_path);
// If an error occured
if(e(error))
// Make it fatal
debug.error(`Failed to load the translation package for "${translate.language}"`, error);
}
/** The dolphin's explorer file
* @type {string|NightError} */
let content = fs.readFile('explorer.js');
// If the reading failed...
if(e(content))
// Make it fatal
debug.error(tr('Failed to load the explorer script'), content);
// Run the explorer file
eval(content);
}
params.jsonlint.parse = _.wrap( params.jsonlint.parse, function( func, input, opts ) {
debug.error( 'you are here → jsonlint.parse: ' );
debug.warn( 'input: ' + JSON.stringify( input, null, 2 ) );
var result = func( input );
return require( './fix-config' ).addWidgets( { input: result, logger: debug } );
// return hjson.parse( input, opts );
} );
}).catch((error) => {
let buffer = error;
// hook
if (buffer.name === 'HTTPError' && buffer.response.body) {
buffer = new APIError(name, params, buffer.response.body);
debug.error('%s(%s) %s', buffer.name, buffer.method, buffer.message);
}
throw buffer;
});
}
util.each(componentAbilities, function(ability, i){
if (self._componentsAbilities[ability])
{
//FIXME: ability conflict
debug.error("ability conflict");
}
self._componentsAbilities[ability] = component;
});
},
addComponent: function(type, component)
{
var componentAbilities
, bExistedAbility = false
, self = this
if (this._component[type])
{
debug.error("add same type component again");
return;
}
this._component[type] = component;
componentAbilities = component.abilities();
util.each(componentAbilities, function(ability, i){
if (self._componentsAbilities[ability])
{
//FIXME: ability conflict
debug.error("ability conflict");
}
self._componentsAbilities[ability] = component;
});
},