Skip to content

Commit

Permalink
show useful error message in toast (#86)
Browse files Browse the repository at this point in the history
* show useful error message in toast

* udpate runs-on commit sha from github sha

Co-authored-by: Devin Rasmussen <[email protected]>
  • Loading branch information
dvnrsn and Devin Rasmussen committed Feb 11, 2022
1 parent 7056336 commit 808e658
Show file tree
Hide file tree
Showing 3 changed files with 7,728 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name:
name:

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: build docker
Expand All @@ -21,7 +21,7 @@ jobs:
test:
needs: build
runs-on: canopytax/toggle-meister:$GITHUB_SHA
runs-on: canopytax/toggle-meister:$CI_COMMIT_SHA

steps:
- name: test
Expand Down
8 changes: 6 additions & 2 deletions tmeister/static/src/toggles/create/create-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ function useCreate({name, api, visibleError}) {
setSaving(false)
setSaved(true)
} else {
throw new Error(`Server responded with status ${response.status}`);
throw response
}
}).catch(err => {
toasts.generalToast(`${visibleError}: ${JSON.stringify(err)}`)
if (err.text) {
err.json().then(text => toasts.generalToast(`${visibleError}: ${text.Message ? text.Message : text}`))
} else {
toasts.generalToast(`${visibleError}: ${err.status ? err.status : ''} ${err.message}`)
}
setSaving(false)
setSaved(false)
throw new Error(err);
Expand Down
Loading

0 comments on commit 808e658

Please sign in to comment.