gbox-errors
Version:
Error handlers
46 lines (29 loc) • 847 B
JavaScript
module.exports = function (err) {
// prepare variables
let response = '';
if (err.attrNames.length > 0) {
response = arrayToString(err.attrNames);
} else if (err.raw['footprint'].keys.length > 0) {
let attributes = [];
for (let key of err.raw['footprint'].keys) {
let tmp = key.split('_');
attributes.push(tmp[1]);
}
response = arrayToString(attributes);
} else {
response = 'unknown ';
}
return response;
function arrayToString(arr) {
// prepare variables
let first = true;
let response = '';
// convert to string
for (let string of arr ) {
if (!first) response += ', ';
response += string;
first = false;
}
return response;
}
};