pug-error
Standard error objects for pug. This module is intended for use by the lexer, parser, loader, linker, code-generator and any plugins.
Installation
npm install pug-error
Usage
var error = require('pug-error');
error(code, message, options)
Create a Pug error object.
code
is a required unique code for the error type that can be used to pinpoint a certain error.
message
is a human-readable explanation of the error.
options
can contain any of the following properties:
filename
: the name of the file causing the errorline
: the offending linecolumn
: the offending columnsrc
: the Pug source, if available, for pretty-printing the error context
The resulting error object is a simple Error object with additional properties given in the arguments.
Caveat: the message
argument is stored in err.msg
, not err.message
, which is occupied with a better-formatted message.
var error = require('pug-error');
var err = error('MY_CODE', 'My message', {line: 3, filename: 'myfile', src: 'foo\nbar\nbaz\nbash\nbing'});
throw err;
License
MIT