StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
54 lines
1.1 KiB
'use strict';
|
|
|
|
var util = require('util');
|
|
var utils = require('../utils');
|
|
|
|
module.exports = function(proto, name) {
|
|
if (!name && proto.constructor) {
|
|
name = proto.constructor.name;
|
|
}
|
|
|
|
/**
|
|
* Format an error
|
|
*/
|
|
|
|
proto.formatError = function(method, id, msg, view) {
|
|
var ctx = this.templatesError[method][id];
|
|
if (!view) view = {relative: ''};
|
|
if (!msg) msg = '';
|
|
|
|
var str = name + '#' + method + ' ' + ctx;
|
|
var reason = util.format(str, msg, view.relative).trim();
|
|
|
|
var err = new Error(reason);
|
|
err.reason = reason;
|
|
err.id = id;
|
|
err.msg = msg;
|
|
return err;
|
|
};
|
|
|
|
/**
|
|
* Rethrow an error in the given context to
|
|
* get better error messages.
|
|
*/
|
|
|
|
proto.rethrow = function(method, err, view, context) {
|
|
if (this.options.rethrow !== true) return err;
|
|
|
|
try {
|
|
var opts = utils.extend({}, this.options.rethrow, {
|
|
data: context,
|
|
fp: view.path
|
|
});
|
|
|
|
utils.rethrow(view.content, opts);
|
|
} catch (e) {
|
|
err.method = method;
|
|
err.reason = e;
|
|
err.view = view;
|
|
err.id = 'rethrow';
|
|
err._called = true;
|
|
return err;
|
|
}
|
|
};
|
|
};
|
|
|