0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 15:52:39 +00:00

better error handling in jsx

This commit is contained in:
Víctor Losada Hernández
2024-05-06 23:32:18 +02:00
parent 51fcb59f09
commit ded78c6639

View File

@@ -263,24 +263,19 @@ const ArchivePage = createClass({
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) {
console.log('render Error: ', error);
let errorMessage;
switch (error.errorCode) {
case '404':
errorMessage = "We didn't find any brew";
errorMessage = "404 - We didn't find any brew";
break;
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;
case '500':
errorMessage = "500 - We don't know what happened."
default:
errorMessage = 'An unexpected error occurred';
}
@@ -291,6 +286,15 @@ const ArchivePage = createClass({
</div>
);
};
if (!brewCollection || brewCollection.length === 0) {
return (
<div className='foundBrews noBrews'>
<h3>No brews found</h3>
</div>
);
};