# conglomerate-error

> HTTP-friendly error objects

Latest version **1.0.3** (published 2016-03-28) · BSD-3-Clause license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-03-28 |
| First published | 2016-03-19 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mark Milstein |
| Maintainers | epiloque |

## Links

- npm: https://www.npmjs.com/package/conglomerate-error
- Repository: https://github.com/eitherlands/conglomerate-error
- Issues: https://github.com/eitherlands/conglomerate-error/issues
- npm.io page: https://npm.io/package/conglomerate-error

## Dependencies (1)

- [conglomerate-assert](https://npm.io/package/conglomerate-assert.md) ^1.1.1

## Recent versions

- 1.0.3 (latest) — 2016-03-28
- 1.0.2 — 2016-03-28
- 1.0.1 — 2016-03-19

## README

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]

# [conglomerate-error](https://github.com/eitherlands/conglomerate-error)

[hapijs/boom](https://github.com/hapijs/boom) for browsers.
Supports all modern browsers, tested on IE 9+, Chrome 16+, FireFox 5+, Safari 6+, Opera 12+.

# [Thanks](https://github.com/eitherlands/conglomerate-error#Thanks)

Thanks to [Eran Hammer](@hueniverse) and @hapijs community for the quality
engineering behind hapi.

Thanks to [Sauce Labs](https://saucelabs.com) for providing the infrastructure
that allows us to run our build in real browsers.

# Documentation

## create

[src/index.js:91-93](https://github.com/eitherlands/conglomerate-error/blob/7e1f892f0963fe0cc201d469a5c58ca2e6c073e2/src/index.js#L91-L93 "Source code on GitHub")

Generates an Error object with decorations where:

**Parameters**

-   `statusCode` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** an HTTP error code number. Must be greater or equal 400.
-   `message` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)=** message string.
-   `data` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)=** additional error data set to error.data property.

Returns **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** error

## Error

[src/index.js:197-217](https://github.com/eitherlands/conglomerate-error/blob/7e1f892f0963fe0cc201d469a5c58ca2e6c073e2/src/index.js#L197-L217 "Source code on GitHub")

**Extends Error**

A decorated error object (instance of Error) which includes the following
properties:

**Properties**

-   `isError` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** if true, indicates this is a decorated Error object instance.
-   `isServer` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** convenience bool indicating status code >= 500.
-   `message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the error message
-   `output` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the formatted response. Can be directly
    manipulated after object construction to return a custom error response.
    -   `output.statusCode` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the HTTP status code (typically 4xx or 5xx).
    -   `output.headers` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object containing any HTTP headers where each
        key is a header name and value is the header content.
    -   `output.payload` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the formatted object used as the
        response payload (stringified). Can be directly manipulated but any changes
        will be lost if reformat() is called.
        -   `output.payload.statusCode` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the HTTP status code
        -   `output.payload.error` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the HTTP status message (e.g. 'Bad Request', 'Internal Server Error')
        -   `output.payload.message` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the error message
-   `reformat` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** rebuilds error.output.

## warning

[src/index.js:197-217](https://github.com/eitherlands/conglomerate-error/blob/7e1f892f0963fe0cc201d469a5c58ca2e6c073e2/src/index.js#L197-L217 "Source code on GitHub")

Prints a warning in the console if it exists.

**Parameters**

-   `message` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The warning message.

Returns **void** 

## wrap

[src/index.js:77-80](https://github.com/eitherlands/conglomerate-error/blob/7e1f892f0963fe0cc201d469a5c58ca2e6c073e2/src/index.js#L77-L80 "Source code on GitHub")

Decorates an error with the properties where:

**Parameters**

-   `error` **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** object to wrap. If error is already a decorated, returns back the same object.
-   `statusCode` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)=** optional HTTP status code (optional, default `500`)
-   `message` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)=** If the error already has a message, it adds the message as a prefix (optional, default `''`)

Returns **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** error

# [License](https://github.com/eitherlands/conglomerate-error#License)

conglomerate-error is released under the terms of the BSD-3-Clause license.

[npm-url]: https://www.npmjs.com/package/conglomerate-error

[npm-image]: https://img.shields.io/npm/v/conglomerate-error.svg

[travis-url]: https://travis-ci.org/eitherlands/conglomerate-error

[travis-image]: https://img.shields.io/travis/eitherlands/conglomerate-error.svg

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