mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 05:32:41 +00:00
better error handling in jsx
This commit is contained in:
@@ -263,24 +263,19 @@ const ArchivePage = createClass({
|
|||||||
|
|
||||||
|
|
||||||
if(title === '') {return (<div className='foundBrews noBrews'><h3>Whenever you want, just start typing...</h3></div>);}
|
if(title === '') {return (<div className='foundBrews noBrews'><h3>Whenever you want, just start typing...</h3></div>);}
|
||||||
if (!brewCollection || brewCollection.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className='foundBrews noBrews'>
|
|
||||||
<h3>No brews found</h3>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('render Error: ', error);
|
console.log('render Error: ', error);
|
||||||
let errorMessage;
|
let errorMessage;
|
||||||
switch (error.errorCode) {
|
switch (error.errorCode) {
|
||||||
case '404':
|
case '404':
|
||||||
errorMessage = "We didn't find any brew";
|
errorMessage = "404 - We didn't find any brew";
|
||||||
break;
|
break;
|
||||||
case '503':
|
case '503':
|
||||||
errorMessage = 'Your search is not specific enough. Too many brews meet this criteria for us to display them.';
|
errorMessage = ' 503 - Your search is not specific enough. Too many brews meet this criteria for us to display them.';
|
||||||
break;
|
break;
|
||||||
case '500':
|
case '500':
|
||||||
|
errorMessage = "500 - We don't know what happened."
|
||||||
default:
|
default:
|
||||||
errorMessage = 'An unexpected error occurred';
|
errorMessage = 'An unexpected error occurred';
|
||||||
}
|
}
|
||||||
@@ -291,6 +286,15 @@ const ArchivePage = createClass({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!brewCollection || brewCollection.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className='foundBrews noBrews'>
|
||||||
|
<h3>No brews found</h3>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user