Actually dispatch errors

This commit is contained in:
Aaron Lindsay 2017-01-03 05:32:19 -05:00
parent ce6660b575
commit 4f940b31a1
4 changed files with 28 additions and 28 deletions

View File

@ -77,7 +77,7 @@ function fetchAll() {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
dispatch(accountsFetched(data.accounts.map(function(json) {
var a = new Account();
@ -87,7 +87,7 @@ function fetchAll() {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -106,7 +106,7 @@ function create(account) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var a = new Account();
a.fromJSON(data);
@ -114,7 +114,7 @@ function create(account) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -133,7 +133,7 @@ function update(account) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var a = new Account();
a.fromJSON(data);
@ -141,7 +141,7 @@ function update(account) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -159,13 +159,13 @@ function remove(account) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
dispatch(accountRemoved(account.AccountId));
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};

View File

@ -77,7 +77,7 @@ function fetchAll() {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
dispatch(securitiesFetched(data.securities.map(function(json) {
var s = new Security();
@ -87,7 +87,7 @@ function fetchAll() {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -106,7 +106,7 @@ function create(security) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var s = new Security();
s.fromJSON(data);
@ -114,7 +114,7 @@ function create(security) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -133,7 +133,7 @@ function update(security) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var s = new Security();
s.fromJSON(data);
@ -141,7 +141,7 @@ function update(security) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -159,13 +159,13 @@ function remove(security) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
dispatch(securityRemoved(security.SecurityId));
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};

View File

@ -38,7 +38,7 @@ function search(searchString, searchType, limit) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else if (data.securities == null) {
dispatch(securityTemplatesSearched(searchString, searchType, new Array()));
} else {
@ -51,7 +51,7 @@ function search(searchString, searchType, limit) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};

View File

@ -74,7 +74,7 @@ function fetch(userId) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var u = new User();
u.fromJSON(data);
@ -82,7 +82,7 @@ function fetch(userId) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -108,7 +108,7 @@ function login(user) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var s = new Session();
s.fromJSON(data);
@ -116,7 +116,7 @@ function login(user) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -133,7 +133,7 @@ function tryResumingSession() {
e.fromJSON(data);
if (e.isError()) {
if (e.ErrorId != 1 /* Not Signed In*/)
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var s = new Session();
s.fromJSON(data);
@ -142,7 +142,7 @@ function tryResumingSession() {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -160,13 +160,13 @@ function logout() {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
dispatch(userLoggedOut());
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};
@ -185,7 +185,7 @@ function update(user) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
dispatch(ErrorActions.serverError(e));
} else {
var u = new User();
u.fromJSON(data);
@ -193,7 +193,7 @@ function update(user) {
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
dispatch(ErrorActions.ajaxError(e));
}
});
};