Permalink
Browse files

[doc] Added examples/*

  • Loading branch information...
1 parent 4537249 commit c069dee813f7564eb288ecb8d9e6eb32deab1339 @indexzero committed Feb 24, 2012
Showing with 29 additions and 0 deletions.
  1. +22 −0 examples/custom-error.js
  2. +7 −0 examples/stack.js
View
@@ -0,0 +1,22 @@
+var util = require('util'),
+ errs = require('../lib/errs');
+
+function MyError () {
+ this.message = 'This is my error; I made it myself. It has a transparent stack trace.';
+}
+
+//
+// Alternatively `MyError.prototype.__proto__ = Error;`
+//
+util.inherits(MyError, Error);
+
+//
+// Register the error type
+//
+errs.register('myerror', MyError);
+
+console.log(
+ errs.create('myerror')
+ .stack
+ .split('\n')
+);
View
@@ -0,0 +1,7 @@
+var errs = require('../lib/errs');
+
+console.log(
+ errs.create('This is an error. There are many like it. It has a transparent stack trace.')
+ .stack
+ .split('\n')
+);

0 comments on commit c069dee

Please sign in to comment.