fix: Catch expected error when shares.info returns 404
This commit is contained in:
parent
d2b9a5c03f
commit
68dcb4de5f
|
@ -6,6 +6,7 @@ import type { Location, RouterHistory, Match } from "react-router-dom";
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { observer, inject } from "mobx-react";
|
import { observer, inject } from "mobx-react";
|
||||||
import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers";
|
import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers";
|
||||||
|
import { NotFoundError, OfflineError } from "utils/errors";
|
||||||
import DocumentComponent from "./Document";
|
import DocumentComponent from "./Document";
|
||||||
import Revision from "models/Revision";
|
import Revision from "models/Revision";
|
||||||
import Document from "models/Document";
|
import Document from "models/Document";
|
||||||
|
@ -19,7 +20,6 @@ import SharesStore from "stores/SharesStore";
|
||||||
import PoliciesStore from "stores/PoliciesStore";
|
import PoliciesStore from "stores/PoliciesStore";
|
||||||
import RevisionsStore from "stores/RevisionsStore";
|
import RevisionsStore from "stores/RevisionsStore";
|
||||||
import UiStore from "stores/UiStore";
|
import UiStore from "stores/UiStore";
|
||||||
import { OfflineError } from "utils/errors";
|
|
||||||
|
|
||||||
type Props = {|
|
type Props = {|
|
||||||
match: Match,
|
match: Match,
|
||||||
|
@ -130,7 +130,11 @@ class DataLoader extends React.Component<Props> {
|
||||||
return this.goToDocumentCanonical();
|
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 isMove = this.props.location.pathname.match(/move$/);
|
||||||
const canRedirect = !revisionId && !isMove && !shareId;
|
const canRedirect = !revisionId && !isMove && !shareId;
|
||||||
|
|
Reference in New Issue