fix: Catch expected error when shares.info returns 404

This commit is contained in:
Tom Moor 2020-08-08 17:55:21 -07:00
parent d2b9a5c03f
commit 68dcb4de5f
1 changed files with 6 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import type { Location, RouterHistory, Match } from "react-router-dom";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers";
import { NotFoundError, OfflineError } from "utils/errors";
import DocumentComponent from "./Document";
import Revision from "models/Revision";
import Document from "models/Document";
@ -19,7 +20,6 @@ import SharesStore from "stores/SharesStore";
import PoliciesStore from "stores/PoliciesStore";
import RevisionsStore from "stores/RevisionsStore";
import UiStore from "stores/UiStore";
import { OfflineError } from "utils/errors";
type Props = {|
match: Match,
@ -130,7 +130,11 @@ class DataLoader extends React.Component<Props> {
return this.goToDocumentCanonical();
}
this.props.shares.fetch(document.id);
this.props.shares.fetch(document.id).catch(err => {
if (!(err instanceof NotFoundError)) {
throw err;
}
});
const isMove = this.props.location.pathname.match(/move$/);
const canRedirect = !revisionId && !isMove && !shareId;