Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

#Mapload utils

MaploadError class

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.

Constructor

MaploadError(message, data = {}, html = null);

message - text message to describe the error data - object to be reported html - html string containing alternative output

toHtml()

Outputs html string


data

Stack Trace


stack trace

toString()

Error: message

State data: data as pretiffied json

Stack Trace: stack trace

async send_error_message(error, subject);

Sends an email a configurable email server, to and from address. error - error object , can be any but has special handling for MaploadError

Email credentials file

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" }

Usage

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"); }

Depandencies

nodemailer

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages