mirror of https://github.com/Seich/Beau.git
Improved error reporting. Started on a new example. Working on Plugins.
This commit is contained in:
parent
f5607f861a
commit
ab19146966
4
beau.js
4
beau.js
|
|
@ -5,9 +5,11 @@ class Beau {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
VERSION: 1,
|
VERSION: 1,
|
||||||
CACHE: false,
|
CACHE: false,
|
||||||
HOST: ''
|
HOST: '',
|
||||||
|
PLUGINS: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.configKeys = Object.keys(this.defaults);
|
this.configKeys = Object.keys(this.defaults);
|
||||||
this.config = this.loadConfig(doc, this.defaults);
|
this.config = this.loadConfig(doc, this.defaults);
|
||||||
this.requests = new RequestList(doc, this.config);
|
this.requests = new RequestList(doc, this.config);
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,11 @@ class Request {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
request.end(res => {
|
request.end(res => {
|
||||||
|
if (res.error !== false) {
|
||||||
|
let error = typeof res.error.code === 'undefined' ? `Invalid Request ${res.error}` : res.error.code;
|
||||||
|
return reject(`HTTP Request failed: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
let results = {
|
let results = {
|
||||||
request: {
|
request: {
|
||||||
headers: res.request.headers,
|
headers: res.request.headers,
|
||||||
|
|
@ -83,7 +88,7 @@ class Request {
|
||||||
|
|
||||||
cache.add(`$${this.ALIAS}`, results);
|
cache.add(`$${this.ALIAS}`, results);
|
||||||
|
|
||||||
resolve(results);
|
return resolve(results);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class RequestList {
|
||||||
.exec()
|
.exec()
|
||||||
.catch(reason => {
|
.catch(reason => {
|
||||||
return Promise
|
return Promise
|
||||||
.reject(`${request.VERB} ${request.ENDPOINT} FAILED. \nDependencies not met:\n${reason}`);
|
.reject(`Request: ${request.VERB} ${request.ENDPOINT} FAILED. \n${reason}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue