This commit is contained in:
William Bartholomew 2016-11-15 17:02:52 -08:00
Родитель 844424f8f9
Коммит 1c044cedb5
1 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -19,26 +19,26 @@ class Crawler {
}
log(thing) {
const args = array_slice(arguments, 1);
const self = this;
if (typeof thing === 'function') {
return () => {
this.logger.verbose(`Enter: ${thing.name}`);
return function () {
const args = array_slice(arguments);
self.logger.verbose(`Promise Function Enter: ${thing.name}`);
const result = thing.apply(self, args);
if (typeof result.then === 'function') {
result.then(
result => { this.logger.verbose(`Success: ${thing.name}`); },
error => { this.logger.error(`Error: ${thing.name}`, error); });
result => { self.logger.verbose(`Promise Function Success: ${thing.name}`); },
error => { self.logger.error(`Promise Function Error: ${thing.name}`, error); });
} else {
this.logger.verbose(`Exit: ${thing.name} : ${result}`);
self.logger.verbose(`Promise Function Exit: ${thing.name}: ${result}`);
}
return result;
};
} else if (typeof thing.then === 'function') {
this.logger.verbose(`Enter: ${message}`);
this.logger.verbose(`Promise Enter: ${message}`);
thing.then(
result => { this.logger.verbose(`Success: ${result} : ${message}`); },
error => { this.logger.error(`Error: ${result} : ${message}`, error); });
result => { this.logger.verbose(`Promise Success: ${result}`); },
error => { this.logger.error(`Promise Error: ${result}`, error); });
return thing;
}
}
@ -213,7 +213,7 @@ class Crawler {
if (status === 403) {
const delay = 2 * 60 * 1000;
self._delayFor(delay);
request.addMeta({ forbiddenDelay: delay});
request.addMeta({ forbiddenDelay: delay });
return request.markRequeue('GitHub throttled: ${request.url}');
}
throw new Error(`Code: ${status} for: ${request.url}`);