Skip to content

Commit

Permalink
Merge pull request #18 from dlmr/fix/dont-require-error-object
Browse files Browse the repository at this point in the history
Remove assumption that we always get an error object
  • Loading branch information
dlmr authored Apr 7, 2017
2 parents daa2a0d + 6a8d42a commit 5a80df7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/RedialContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,16 @@ export default class RedialContext extends Component {
bail
)
.catch((error) => {
let afterTransition = false;
if (error && error.afterTransition !== undefined) {
afterTransition = error.afterTransition;
error = error.error; // eslint-disable-line
}

this.props.onError(error, {
reason: bail() || 'other',
// If not defined before it's a beforeTransition error
beforeTransition: error.afterTransition === undefined,
beforeTransition: !afterTransition,
router: this.props.renderProps.router,
abort: () => this.abort(true, abort),
});
Expand Down Expand Up @@ -288,10 +294,7 @@ export default class RedialContext extends Component {
.then(() => {
this.props.onCompleted('afterTransition');
})
.catch((error) => {
error.afterTransition = true; // eslint-disable-line
return Promise.reject(error);
});
.catch((error) => Promise.reject({ error, afterTransition: true }));
} else if (this.completed.afterTransition) {
this.completed.afterTransition = false;
this.props.onCompleted('afterTransition');
Expand Down

0 comments on commit 5a80df7

Please sign in to comment.