Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
Adding explanations for how to screw up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Williams committed Jun 20, 2016
1 parent 65787a9 commit cee8adb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ You're set! _microboot_ will now first run all JS files found in the `boot/datab

If you want to know more about the syntax used for specifying recursiveness and the like, take a look at [glob](https://github.com/isaacs/node-glob); it's what's behind _microboot_'s loader.

## Failing to initialise

If something screws up, you _should_ want to stop your app starting. If that's the case, you can throw an error during a step to stop things in their tracks.

For a _synchronous_ step, just go ahead and throw:

``` js
module.exports = function my_broken_api () {
throw new Error('Oh no! It\'s all gone wrong!')
}
```

For an _asynchronous_ step, return your error as the first argument of the callback:

``` js
module.exports = function my_broken_api (done) {
startUpApi(function (err) {
if (err) {
return done(err)
}

return done()
})
}
```

## Examples

Yay examples! These all assume the following directory tree, the root representing your project's current working directory.
Expand Down

0 comments on commit cee8adb

Please sign in to comment.