Skip to content

Commit

Permalink
Add Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Oct 7, 2012
1 parent b942854 commit 6f84151
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.6
- 0.8
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Because JavaScript errors could be a lot more useful.
[![build status](https://secure.travis-ci.org/mjijackson/usererror.png)](http://travis-ci.org/mjijackson/usererror)

UserError: Because JavaScript errors could be a lot more useful.

This package provides a base constructor (i.e. "class") that makes JavaScript
errors on V8 a lot more useful. Errors built using this class have the following
Expand All @@ -11,23 +13,21 @@ benefits:

Install this package using [npm](http://npmjs.org):

``` bash
$ npm install usererror
```
$ npm install usererror

You are also free to [browse or download the source](https://github.com/mjijackson/error).

## Usage

The simplest usage for this class is:

``` javascript
var UserError = require("usererror");
```javascript
var UserError = require('usererror');

try {
throw new UserError("Kaboom!");
throw new UserError('Kaboom!');
} catch (e) {
console.log(e.message);
console.log(e.message);
}
```

Expand All @@ -52,29 +52,29 @@ expectation for what class(es) of errors they can expect.
Note: The `stack` property still works as you would expect, and only contains
the stack trace for the error one level deep.

``` javascript
var util = require("util"),
UserError = require("usererror");
```javascript
var util = require('util');
var UserError = require('usererror');

function LoginFailedError(cause) {
UserError.call(this, "Login failed", cause);
UserError.call(this, 'Login failed', cause);
}

util.inherits(LoginFailedError, UserError);

function loginUser(userId, callback) {
connectToDatabase(function (err, db) {
if (err) {
callback(new LoginFailedError(err));
}
connectToDatabase(function (err, db) {
if (err) {
callback(new LoginFailedError(err));
}

// Login the user.
});
// Login the user.
});
}

loginUser(myUserId, function (err) {
console.log(err.fullStack); // Recursive stack trace.
console.log(err.stack); // Single-level stack trace.
console.log(err.fullStack); // Recursive stack trace.
console.log(err.stack); // Single-level stack trace.
});
```

Expand Down

0 comments on commit 6f84151

Please sign in to comment.