Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iced-error

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iced-error

An error-handling class written with/for IcedCoffeeScript

  • 0.0.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
130K
decreased by-2.87%
Maintainers
1
Weekly downloads
 
Created
Source

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:


{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:

{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:

{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!

{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

FAQs

Package last updated on 15 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc