mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
Finalize ReactError component
This commit is contained in:
parent
0a67766aba
commit
3ce63c33bf
@ -55,7 +55,7 @@ let EditionContainer = React.createClass({
|
|||||||
const { editionError } = this.state;
|
const { editionError } = this.state;
|
||||||
|
|
||||||
if(editionError && editionError.status === 404) {
|
if(editionError && editionError.status === 404) {
|
||||||
this.throws(new ResourceNotFoundError(getLangText('Oops, the edition you\'re looking for doesn\'t exist.')));
|
this.throws(new ResourceNotFoundError(getLangText("Oops, the edition you're looking for doesn't exist.")));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ let PieceContainer = React.createClass({
|
|||||||
const { pieceError } = this.state;
|
const { pieceError } = this.state;
|
||||||
|
|
||||||
if(pieceError && pieceError.status === 404) {
|
if(pieceError && pieceError.status === 404) {
|
||||||
this.throws(new ResourceNotFoundError(getLangText('Oops, the piece you\'re looking for doesn\'t exist.')));
|
this.throws(new ResourceNotFoundError(getLangText("Oops, the piece you're looking for doesn't exist.")));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ let ErrorNotFoundPage = React.createClass({
|
|||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
message: getLangText('Oops, the page you are looking for does not exist.')
|
message: getLangText("Oops, the page you are looking for doesn't exist.")
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4,9 +4,12 @@ import invariant from 'invariant';
|
|||||||
|
|
||||||
const ReactError = {
|
const ReactError = {
|
||||||
throws(err) {
|
throws(err) {
|
||||||
invariant(err.handler, 'Error thrown to ReactError did not have a `handler` function');
|
if(!err.handler) {
|
||||||
console.logGlobal('Error thrown to ReactError did not have a `handler` function');
|
invariant(err.handler, 'Error thrown to ReactError did not have a `handler` function');
|
||||||
err.handler(this, err);
|
console.logGlobal('Error thrown to ReactError did not have a `handler` function');
|
||||||
|
} else {
|
||||||
|
err.handler(this, err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ export class ResourceNotFoundError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handler(component, err) {
|
handler(component, err) {
|
||||||
const { displayName } = component.constructor;
|
const monkeyPatchedKey = `_${this.name}MonkeyPatched`;
|
||||||
const monkeyPatchedKey = typeof displayName === 'string' ? `_${displayName}MonkeyPatched`
|
|
||||||
: '_monkeyPatched';
|
|
||||||
|
|
||||||
if(!component.state[monkeyPatchedKey]) {
|
if(!component.state[monkeyPatchedKey]) {
|
||||||
component.render = () => <ErrorNotFoundPage message={err.message} />;
|
component.render = () => <ErrorNotFoundPage message={err.message} />;
|
||||||
|
Loading…
Reference in New Issue
Block a user