# iced-error

> An error-handling class written with/for IcedCoffeeScript

Latest version **0.0.13** (published 2018-10-15) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2018-10-15 |
| First published | 2013-06-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | maxtaco |

## Links

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

## Recent versions

- 0.0.13 (latest) — 2018-10-15
- 0.0.12 — 2017-09-21
- 0.0.10 — 2017-03-28
- 0.0.9 — 2014-06-03
- 0.0.8 — 2014-01-31
- 0.0.7 — 2014-01-22
- 0.0.6 — 2013-09-25
- 0.0.5 — 2013-06-09
- 0.0.4 — 2013-06-04
- 0.0.3 — 2013-06-03
- 0.0.2 — 2013-06-03
- 0.0.1 — 2013-06-03

## README

# IcedErrors

An integrated error system for dealing with errors, written for
and with IcedCoffeeScript.  I found myself doing this stuff everytime
I wrote a new project, so better to standardize it.

## Enumerated Error Types

In your `lib/error.iced` file:

```coffeescript

{make_errors} = require 'iced-error'
exports.E = make_errors
  NOT_FOUND : "Requested resource was not found"
  BAD_MAC : "MAC failed on header"
  INVAL : "Invalid value"
  DB_INSERT : "Error inserting into the database"  
```

In your `foo.iced` file:

```coffeescript
{E} = require './lib/error'

console.log E.OK                # prints 0
console.log E.NOT_FOUND         # prints 100
console.log E.msg[E.NOT_FOUND]  # prints "Requested resource was not found"
console.log E.msg.NOT_FOUND]    # prints "Requested resource was not found"
console.log E.name.NOT_FOUND    # prints "NOT_FOUND"
console.log E.name[E.NOT_FOUND] # prints "NOT_FOUND"
```

You can also use predefined Error classes:

```coffeescript
{E} = require './lib/error'

# You can throw these errors too
throw new E.NotFoundError("your file") 

# Will print [NotFoundError: your file (code 100)]
console.log new E.NotFoundError "your file"

# Will print "your file"
console.log (new E.NotFoundError "your file").message

# Will print 100
console.log (new E.NotFoundError "your file").code
```

## Error Short Circuiters

Catch errors all at once, not everywhere! 

```coffeescript
{make_esc} = require 'iced-error'
my_fn = (cb) ->
  esc = make_esc gcb, "my_fn"
  await socket.get 'image id', esc defer id
  await Image.findById id, esc defer image
  await check_permissions user, image, esc defer permitted
  gcb null, image
```

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