Return error in request
This commit is contained in:
11
lib/store.js
11
lib/store.js
@ -5,12 +5,23 @@ var store;
|
||||
var adapter;
|
||||
var Report;
|
||||
|
||||
function error(msg) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
return resolve({ error: msg });
|
||||
});
|
||||
}
|
||||
|
||||
function add(data) {
|
||||
if (!data.type || !data.payload) {
|
||||
return error('Required parameters aren\'t specified.');
|
||||
}
|
||||
|
||||
var obj = {
|
||||
id: uuid.v4(),
|
||||
type: data.type,
|
||||
payload: data.payload
|
||||
};
|
||||
|
||||
if (!adapter) {
|
||||
return new Promise(function(resolve) {
|
||||
var report = Report.inject(obj);
|
||||
|
Reference in New Issue
Block a user