Skip to content

Commit

Permalink
Enhance error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Mar 9, 2024
1 parent cf8f2bd commit 040f1dd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
24 changes: 12 additions & 12 deletions acceptance/cypress/tests/blocks-searchkit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ describe('Searchkit Block Tests', () => {
force: true,
});

// block configuration index server
cy.get('input#field-backend_url').type('http://localhost:55001/plone')
cy.get('input#field-frontend_url').type('http://localhost:3000')
// block configuration allowed types and states
cy.get("#field-allowed_content_types").click();
cy.get("#field-allowed_content_types .react-select__option")
.contains('Page')
.click();
cy.get("#field-allowed_review_states").click();
cy.get("#field-allowed_review_states .react-select__option")
.contains('Private')
.click();
// // block configuration index server
// cy.get('input#field-backend_url').type('http://localhost:55001/plone')
// cy.get('input#field-frontend_url').type('http://localhost:3000')
// // block configuration allowed types and states
// cy.get("#field-allowed_content_types").click();
// cy.get("#field-allowed_content_types .react-select__option")
// .contains('Page')
// .click();
// cy.get("#field-allowed_review_states").click();
// cy.get("#field-allowed_review_states .react-select__option")
// .contains('Private')
// .click();

cy.get('#toolbar-save').click();
cy.visit('/searching');
Expand Down
6 changes: 6 additions & 0 deletions src/components/Searchkit/ESSearchApi.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,15 @@ export class PloneSearchApi {
});
// let results = await this.responseSerializer.serialize(response.data);
let results = await response.json();
if (results.message) {
throw results
// throw new Error(`${results.type} ${results.message}`);
}
results = this.responseSerializer.serialize(results);
return results;
} catch (error) {
console.debug('ESSearchApi. error:');
console.debug(error);
throw error;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Searchkit/Error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Header, Segment } from 'semantic-ui-react';
import { FormattedMessage } from 'react-intl';

const Error = ({ error }) => {
const stateError = useSelector((state) => state.results?.error);

return stateError?.name ? (
return error?.type ? (
<Segment inverted color="red" secondary>
<Header icon>
<h3>
Expand All @@ -15,7 +14,7 @@ const Error = ({ error }) => {
/>
</h3>
</Header>
<b>{stateError?.name}:</b> <i>{stateError?.message}</i>
<b>{error?.type}:</b> <i>{error?.message}</i>
</Segment>
) : null;
};
Expand Down
3 changes: 1 addition & 2 deletions src/components/Searchkit/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Results extends Component {
<Grid>
<Grid.Column width={4}>
<Count />
<div>DEBUG1 {JSON.stringify(this.props.currentResultsState?.error)}</div>
</Grid.Column>
<Grid.Column width={6}>
<Sort
Expand All @@ -67,7 +66,7 @@ class Results extends Component {
<Pagination options={{ size: 'small' }} />
</Grid>
</div>
) : <div>DEBUG2 {JSON.stringify(this.props.currentResultsState?.error)}</div>;
) : null;
}
}

Expand Down

0 comments on commit 040f1dd

Please sign in to comment.