Skip to content

Commit

Permalink
Merge pull request #486 from Cryptonomic/as-errors
Browse files Browse the repository at this point in the history
Error handling
  • Loading branch information
vishakh authored Apr 27, 2021
2 parents 50260af + f204a60 commit 2dfbe52
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 1 addition & 11 deletions src/containers/Homepage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,7 @@ class Home extends React.Component<Props, States> {
</Padding>
</Container>
</WhiteBg>
{/* <Footer>
<Container maxWidth="lg">
<ListContainer>
<ListItem>An open-source product by Cryptonomic</ListItem>
<ListItem>Powered by Conseil</ListItem>
<ListItem>Built with ConseilJS</ListItem>
<ListItem>Version March 2020 Release 8.1-84e17bb</ListItem>
</ListContainer>
</Container>
</Footer> */}
<Footer/>
<Footer />
<Dialog open={isError} onClose={this.handleErrorClose} aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description">
<DialogTitle id="alert-dialog-title">Error</DialogTitle>
<DialogContentWrapper>
Expand Down
1 change: 0 additions & 1 deletion src/containers/Homepage/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Config } from '../../types';
import { RouteComponentProps } from 'react-router-dom';

export interface OwnProps {

classes: any;
hourlytransactions: Transactions[];
isError: boolean;
Expand Down
10 changes: 7 additions & 3 deletions src/reducers/app/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,15 @@ const loadAttributes = (query: string) => async (dispatch: any, state: any) => {
let injectedMetadata: any = {};
if (state().app.selectedConfig.metadataOverrideUrl) {
try {
const metadata = await fetch(state().app.selectedConfig.metadataOverrideUrl).then(response => response.text());
const metadata = await fetch(state().app.selectedConfig.metadataOverrideUrl)
.then(response => response.text())
.catch(e => "" );

await hocon().then((instance) => {
const cfg = new instance.Config(metadata);
injectedMetadata = JSON.parse(cfg.toJSON());
cfg.delete();
});
}).catch(e => {});
} catch (err) {
// meh
}
Expand Down Expand Up @@ -503,9 +505,11 @@ export const initLoad = (props: InitLoad) => async (dispatch: any, state: any) =
let selectedEntity = state().app.entities.find((e: EntityDefinition) => e.name === entity)?.name;

// Not valid entity change to first
if (!selectedEntity) {
if (!selectedEntity && config.entities && config.entities.length > 0) {
selectedEntity = config.entities[0];
history.replace(`/${config.platform}/${config.network}/${selectedEntity}`);
} else if (!selectedEntity && (!config.entities || config.entities.length === 0)) {
throw new Error(`Missing configuration property: "entities" for ${config.platform}/${config.network}`);
}

await dispatch(setEntityAction(selectedEntity));
Expand Down
7 changes: 7 additions & 0 deletions src/reducers/message/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export function clearMessageAction() {
}

export function createMessageAction(message: string, isError: boolean) {
if (isError) {
try { throw new Error(message); }
catch (err) {
console.log(err.message);
console.log(err.stack);
}
}
return {
type: ADD_MESSAGE,
message,
Expand Down

0 comments on commit 2dfbe52

Please sign in to comment.