0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-25 20:33:51 +00:00

error 500 catch and show

This commit is contained in:
Víctor Losada Hernández
2024-01-28 15:57:51 +01:00
parent cccebd8494
commit 8aec5dbba6
2 changed files with 10 additions and 3 deletions

View File

@@ -41,7 +41,7 @@ const ArchivePage = createClass({
this.setState({ searching: true, error: null });
request
.get(`/archive/${this.state.title}`)
.then((res) => this.setState({ brewCollection: res.body.brews }, this.setState({ limit: res.body.message})))
.then((res) => this.setState({ brewCollection: res.body.brews }, this.setState({ limit: res.body.message}, this.setState({ error: null}))))
.catch((err) => this.setState({ error: err }))
.finally(() => this.setState({ searching: false }));
},
@@ -62,6 +62,14 @@ const ArchivePage = createClass({
renderFoundBrews() {
const brews = this.state.brewCollection;
console.log('brews: ',brews);
if (this.state.error !== null) {
return(
<div className="foundBrews noBrews">
<h2>I'm sorry, your request didn't work</h2>
<p>Your search is not enough specific, too many brews meet this criteria for us to forward them.</p>
</div>
);
}
if (!brews || brews.length === 0) {
return(

View File

@@ -11,9 +11,8 @@ body {
height: 100%;
background-color: #2C3E50;
h1,h2,h3 {
h1,h2,h3,p {
font-family: 'Open Sans';
font-size: 30px;
color: white;
font-weight: 900;
}