okay
Bubble errors back up your big ol' nested callback chain.
If domains are in use, defer the error to the domain's error handler by using process.domain.intercept
transparently.
without okay
{ fs;};
with okay
var ok = ; { fs
The same code with annotations:
var ok = ; { //if path does not exist, bubble the error out to the //callback function right away //if there was no error, call the new error-less cb fs
okay also supports a single callback:
{ //if there is an error with fs.readDir, THROW it //if there was no error, call the new error-less callback fs
or even no callback at all:
//if there is an error with fs.writeFile, THROW it//if there was no error, do nothing fs;
domains
Throwing errors is probably not what you want to do.
Okay
comes in really handy if you are using domains. It transparently passes the error back into the active domain if it exists, or it calls your callback with the error parameter already removed in the happy circumstance where there is no error. It's basically shorthand for process.domain.intercept
but will fall back to throwing exceptions if domains are not activated or you're currently not bound to a domain.
var ok = ;var domain = ;var count = 0;var { var requestDomain = domain; reqid = + count++; requestDomain; requestDomain; requestDomain; process} var serverDomain = domain;serverDomain;serverDomain;
express + okay
var ok = ;
coffee-script + express + okay
ok = require "okay"app.get "/", (req, res, next) -> fs.readFile "file.txt", "utf8", ok next, (contents) -> res.send(contents)
mocha + okay
var ok = ;;
code golf, baby.
license
MIT