Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
README: Updates error info.
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Feb 15, 2015
1 parent 6dc6c63 commit 60201f7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The API for using node-sass has changed, so that now there is only one variable
`data` is a `String` containing the scss to be rendered by [libsass]. One of this or `file` options are required, for both render and renderSync. It is recommended that you use the `includePaths` option in conjunction with this, as otherwise [libsass] may have trouble finding files imported via the `@import` directive.

#### success
`success` is a `Function` to be called upon successful rendering of the scss to css. This option is required but only for the render function. If provided to renderSync it will be ignored.
`success` is a `Function` to be called upon successful rendering of the scss to css. This option is required but only for the render function. If provided to `renderSync` it will be ignored. The error object take

The callback function is passed a results object, containing the following keys:

Expand All @@ -89,7 +89,17 @@ The callback function is passed a results object, containing the following keys:
* `includedFiles` - Absolute paths to all related scss files in no particular order.

#### error
`error` is a `Function` to be called upon occurrence of an error when rendering the scss to css. This option is optional, and only applies to the render function. If provided to renderSync it will be ignored.
`error` is a `Function` to be called upon occurrence of an error when rendering the scss to css. This option is optional, and only applies to the render function.

The callback function is passed an error object, containing the following keys:

* `message` - The error message.
* `line` - The line number of error.
* `column` - The column number of error.
* `status` - The status code.
* `file` - The filename of error. In case `file` option was not set (in favour of `data`), this will reflect the value `stdin`.

Note: If this option is provided to renderSync it will be ignored. In case of `renderSync` the error is thrown to stderr, which is try-catchable. In catch block, the same error object will be received.

#### importer (starting from v2)
`importer` is a `Function` to be called when libsass parser encounters the import directive. If present, libsass will call node-sass and let the user change file, data or both during the compilation. This option is optional, and applies to both render and renderSync functions. Also, it can either return object of form `{file:'..', contents: '..'}` or send it back via `done({})`. Note in renderSync or render, there is no restriction imposed on using `done()` callback or `return` statement (dispite of the asnchrony difference).
Expand Down Expand Up @@ -141,10 +151,10 @@ sass.render({
console.log(result.stats);
console.log(result.map)
},
error: function(error) {
error: function(error) { // starting v2.1 error is an Error-typed object
// error is an object: v2 change
console.log(error.message);
console.log(error.code);
console.log(error.status); // changed from code to status in v2.1
console.log(error.line);
console.log(error.column); // new in v2
},
Expand Down

0 comments on commit 60201f7

Please # to comment.