Skip to content

Feature/cleanup #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test custom error page
  • Loading branch information
ShMcK committed Jan 29, 2020
commit 409df4763437433af524515633acfcb6fa723dea
1 change: 1 addition & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface MachineStateSchema {
Initialize: {}
Summary: {}
LoadNext: {}
Error: {}
Level: {
states: {
Load: {}
Expand Down
5 changes: 4 additions & 1 deletion web-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ const Routes = () => {
<LoadingPage text="Launching..." context={{} as CR.MachineContext} />
</Route>
<Route path={'Start.Error'}>
<div>Error</div>
<div>Something went wrong wrong</div>
</Route>
<Route path="Start.SelectTutorial">
<NewPage send={tempSend} context={{} as CR.MachineContext} />
</Route>
<Route path="Start.ContinueTutorial">
<ContinuePage send={tempSend} context={{} as CR.MachineContext} />
</Route>
<Route path={'Tutorial.Error'}>
<div>Something went wrong wrong</div>
</Route>
<Route path="Tutorial.Initialize">
<LoadingPage text="Initializing..." context={{} as CR.MachineContext} />
</Route>
Expand Down
14 changes: 11 additions & 3 deletions web-app/src/components/Error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@ const styles = {
color: '#D8000C',
backgroundColor: '#FFBABA',
padding: '1rem',
width: '100%',
height: '100%',
},
}

interface Props {
error: ApolloError
error?: ApolloError
}

const ErrorView = ({ error }: Props) => {
// log error
React.useEffect(() => {
console.log(error)
onError(error)
if (error) {
console.log(error)
onError(error)
}
}, [])

if (!error) {
return null
}

return (
<div css={styles.container}>
<h1>Error</h1>
Expand Down
3 changes: 2 additions & 1 deletion web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ export const createMachine = (options: any) => {
}),
},
onError: {
target: 'Summary',
target: 'Error',
actions: assign({
error: (context, event) => event.data,
}),
},
},
},
Error: {},
Summary: {
on: {
LOAD_TUTORIAL: {
Expand Down
20 changes: 10 additions & 10 deletions web-app/src/services/state/services/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ export async function authenticate(context: CR.MachineContext): Promise<any> {
// let message
if (error.message.match(/Network error:/)) {
return Promise.reject({
error: {
title: 'Network Error',
description: 'Make sure you have an Internet connection. Restart and try again',
},
title: 'Network Error',
description: 'Make sure you have an Internet connection. Restart and try again',
})
} else {
return Promise.reject({
error: {
title: 'Server Error',
description: error.message,
},
title: 'Server Error',
description: error.message,
})
}
})

if (!result || !result.data) {
const error = new Error('Authentication request responded with no data')
const message = 'Authentication request responded with no data'
const error = new Error()
console.log(error)
onError(error)
return
return Promise.reject({
title: message,
description: 'Something went wrong.',
})
}
const { token } = result.data.editorLogin
// add token to headers
Expand Down