Skip to content

Commit 2a3157f

Browse files
committed
Add doc for custom Error
- Add NPM badge - Update basic example
1 parent da35f59 commit 2a3157f

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
> A simple way to structure your web scraper.
44
5+
[![npm version](https://badge.fury.io/js/yolo-scraper.svg)](https://badge.fury.io/js/yolo-scraper)
56
[![Build Status](https://travis-ci.org/masterT/yolo-scraper.svg?branch=master)](https://travis-ci.org/masterT/yolo-scraper)
67
[![Dependency Status](https://gemnasium.com/badges/github.com/masterT/yolo-scraper.svg)](https://gemnasium.com/github.com/masterT/yolo-scraper)
78

@@ -74,6 +75,14 @@ scraper('masterT', function (error, data) {
7475

7576
## documentation
7677

78+
### `ValidationError`
79+
80+
_Error_ instance with additional _Object_ property `errorObjects` which content all the error information, see [ajv error](https://github.com/epoberezkin/ajv#error-objects).
81+
82+
### `ListValidationError`
83+
84+
_Error_ instance with additional _Array_ property `validationError` of `ValidationError` instance.
85+
7786
### `createScraper(options)`
7887

7988
Returned a scraper function defined by the `options`.

examples/basic.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ var scraper = yoloScraper.createScraper({
3737

3838

3939
scraper('masterT', function (error, data) {
40-
console.log('error:', error);
41-
console.log('data:', data);
40+
if (error) {
41+
console.log('error:', error);
42+
} else {
43+
console.log('data:', data);
44+
}
4245
});

0 commit comments

Comments
 (0)