# pug-error

> Standard error objects for pug

Latest version **2.1.0** (published 2024-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install pug-error
pnpm add pug-error
yarn add pug-error
bun add pug-error
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; popular repo.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2024-05-24 |
| First published | 2015-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21847 |
| Author | Forbes Lindesay |
| Maintainers | forbeslindesay, pug-bot |
| Keywords | pug |

## Links

- npm: https://www.npmjs.com/package/pug-error
- Repository: https://github.com/pugjs/pug/tree/master/packages/pug-error
- npm.io page: https://npm.io/package/pug-error

## Recent versions

- 2.1.0 (latest) — 2024-05-24
- 2.1.0-canary-14 (canary) — 2024-05-24
- 2.1.0-canary-13 — 2021-12-23
- 2.0.0 — 2020-05-25
- 2.0.0-canary-2 — 2020-05-25
- 2.0.0-canary-1 — 2020-05-24
- 1.3.3 — 2019-06-18
- 1.3.2 — 2017-01-24
- 1.3.1 — 2016-06-02
- 1.3.0 — 2015-12-23
- 0.0.0 — 2015-12-04

## README

# pug-error

Standard error objects for pug.  This module is intended for use by the lexer, parser, loader, linker, code-generator and any plugins.

[![Build Status](https://img.shields.io/travis/pugjs/pug-error/master.svg)](https://travis-ci.org/pugjs/pug-error)
[![Dependencies Status](https://david-dm.org/pugjs/pug/status.svg?path=packages/pug-error)](https://david-dm.org/pugjs/pug?path=packages/pug-error)
[![NPM version](https://img.shields.io/npm/v/pug-error.svg)](https://www.npmjs.org/package/pug-error)

## Installation

    npm install pug-error

## Usage

```js
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 error
- `line`: the offending line
- `column`: the offending column
- `src`: 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.

```js
var error = require('pug-error');

var err = error('MY_CODE', 'My message', {line: 3, filename: 'myfile', src: 'foo\nbar\nbaz\nbash\nbing'});
// { code: 'PUG:MY_CODE',
//   msg: 'My message',
//   line: 3,
//   column: undefined,
//   filename: 'myfile',
//   src: 'foo\nbar\nbaz\nbash\nbing',
//   message: 'myfile:3\n    1| foo\n    2| bar\n  > 3| baz\n    4| bash\n    5| bing\n\nMy message' }

throw err;
```

## License

  MIT

---
_Source: https://npm.io/package/pug-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
