Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
adjust controller and triggers.saveComment to a new way of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RusAlex committed Nov 5, 2016
1 parent 51931c7 commit 04400ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/api/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,6 @@ export default class ApiController {
}).fetch({ require: true });
} catch (e) {
ctx.status = 404;
ctx.body = { error: e.message };
return;
}

Expand Down
16 changes: 7 additions & 9 deletions src/triggers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,16 +762,14 @@ export class ActionsTrigger {
try {
const responseBody = await this.client.saveComment(postId, commentId, text);

if (responseBody) {
if (responseBody.error) {
this.dispatch(a.comments.saveCommentFailure(postId, commentId, responseBody.error));
} else {
this.dispatch(a.comments.setPostComments(postId, responseBody));
this.dispatch(a.comments.saveCommentSuccess(postId, commentId));
}
}
this.dispatch(a.comments.setPostComments(postId, responseBody));
this.dispatch(a.comments.saveCommentSuccess(postId, commentId));
} catch (e) {
this.dispatch(a.comments.saveCommentFailure(postId, commentId, e.message));
if (e.response && ('error' in e.response)) {
this.dispatch(a.comments.deleteCommentFailure(postId, commentId, e.response.error));
} else {
this.dispatch(a.comments.saveCommentFailure(postId, commentId, e.message));
}
}
};

Expand Down

0 comments on commit 04400ee

Please sign in to comment.