Fix error dispatching

In other words, actually do it...
This commit is contained in:
Aaron Lindsay 2017-01-02 21:00:12 -05:00
parent 17d87a2b30
commit b4b2b20c28
3 changed files with 26 additions and 26 deletions

View File

@ -70,7 +70,7 @@ function fetchAll() {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(attendeesFetched(data.attendees.map(function(json) { dispatch(attendeesFetched(data.attendees.map(function(json) {
var a = new Attendee(); var a = new Attendee();
@ -80,7 +80,7 @@ function fetchAll() {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -99,7 +99,7 @@ function create(attendee) {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
var a = new Attendee(); var a = new Attendee();
a.fromJSON(data); a.fromJSON(data);
@ -107,7 +107,7 @@ function create(attendee) {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -125,7 +125,7 @@ function fetchPopular() {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(popularAttendeesFetched(data.popularattendees.map(function(json) { dispatch(popularAttendeesFetched(data.popularattendees.map(function(json) {
var a = new PopularAttendee(); var a = new PopularAttendee();
@ -135,7 +135,7 @@ function fetchPopular() {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -153,13 +153,13 @@ function remove(attendee) {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(attendeeRemoved(attendee.AttendeeId)); dispatch(attendeeRemoved(attendee.AttendeeId));
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };

View File

@ -71,7 +71,7 @@ function fetchAll() {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(suggestionsFetched(data.suggestions.map(function(json) { dispatch(suggestionsFetched(data.suggestions.map(function(json) {
var a = new Suggestion(); var a = new Suggestion();
@ -81,7 +81,7 @@ function fetchAll() {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -100,7 +100,7 @@ function create(suggestion) {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
var a = new Suggestion(); var a = new Suggestion();
a.fromJSON(data); a.fromJSON(data);
@ -108,7 +108,7 @@ function create(suggestion) {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -126,7 +126,7 @@ function fetchPopular() {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(popularSuggestionsFetched(data.popularsuggestions.map(function(json) { dispatch(popularSuggestionsFetched(data.popularsuggestions.map(function(json) {
var a = new PopularSuggestion(); var a = new PopularSuggestion();
@ -136,7 +136,7 @@ function fetchPopular() {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -154,13 +154,13 @@ function remove(suggestion) {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(suggestionRemoved(suggestion.SuggestionId)); dispatch(suggestionRemoved(suggestion.SuggestionId));
} }
}, },
error: function(jqXHR, status, error) { 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(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
var u = new User(); var u = new User();
u.fromJSON(data); u.fromJSON(data);
@ -82,7 +82,7 @@ function fetch(userId) {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -110,7 +110,7 @@ function login(user) {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
var s = new Session(); var s = new Session();
s.fromJSON(data); s.fromJSON(data);
@ -118,7 +118,7 @@ function login(user) {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -135,7 +135,7 @@ function tryResumingSession() {
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
if (e.ErrorId != 1 /* Not Signed In*/) if (e.ErrorId != 1 /* Not Signed In*/)
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
var s = new Session(); var s = new Session();
s.fromJSON(data); s.fromJSON(data);
@ -144,7 +144,7 @@ function tryResumingSession() {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -162,13 +162,13 @@ function logout() {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
dispatch(userLoggedOut()); dispatch(userLoggedOut());
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };
@ -187,7 +187,7 @@ function update(user) {
var e = new Error(); var e = new Error();
e.fromJSON(data); e.fromJSON(data);
if (e.isError()) { if (e.isError()) {
ErrorActions.serverError(e); dispatch(ErrorActions.serverError(e));
} else { } else {
var u = new User(); var u = new User();
u.fromJSON(data); u.fromJSON(data);
@ -195,7 +195,7 @@ function update(user) {
} }
}, },
error: function(jqXHR, status, error) { error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e); dispatch(ErrorActions.ajaxError(e));
} }
}); });
}; };