#Mapload utils
Defines a class MaploadError which superclasses Error, allowing an object which can contain state values and an html string. As well as toString it also supports toHtml.
MaploadError(message, data = {}, html = null);
message - text message to describe the error data - object to be reported html - html string containing alternative output
Outputs html string
data
stack trace
Stack Trace:
stack trace
Sends an email a configurable email server, to and from address.
error - error object , can be any but has special handling for MaploadError
Email configuration is stored in ~/.credentials/system_email/email_credentials.json
A constant at the head of the class will need editing to contain the actual path.
The credentials file should contain a json object with the following attributes:
{
"host":"emailhost.co.uk",
"port":465,
"secure":true,
"user":"user@emailhost.co.uk",
"pass":"secret",
"from":"systems@emailhost.co.uk",
"to":"me@emailhost.co.uk"
}
const error_handler = require('error_handler/error_handler.js');
const LADCDNM = "LAD23CD";
try{
.... missing_keys contains an array indicating which required keys from the header of a csv file are missing
if ( missing_keys.length > 0){
let msg = "Some attributes were not available:\n";
let html = '
The following attributes were not available:<:p>
';
for(const k of missing_keys){
html += '- ' + k.key + ' : ' + k.row_key + '
';
}
html += '
';
throw new error_handler.MaploadError(
msg,
msgdata,
html
);
}
}catch(error){
error_handler.send_error_message(error,"ONS UPRN Load error");
}
nodemailer