aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/components/github/api.js
diff options
context:
space:
mode:
authorNick Coutsos <[email protected]>2021-11-07 22:25:15 -0500
committerNick Coutsos <[email protected]>2021-11-07 22:25:15 -0500
commitc51b142abde5af966e469b74031477fcbfa5af22 (patch)
tree3b4d4ccb7ae8f5075794fee94b6e67dbfdb0b9da /application/components/github/api.js
parent84a64acec666019df821d40812a61fe9ae52a461 (diff)
downloadkeymap-editor-c51b142abde5af966e469b74031477fcbfa5af22.tar.gz
keymap-editor-c51b142abde5af966e469b74031477fcbfa5af22.zip
Display load errors in UI
Diffstat (limited to 'application/components/github/api.js')
-rw-r--r--application/components/github/api.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/application/components/github/api.js b/application/components/github/api.js
index a7cbfbb..cce9aec 100644
--- a/application/components/github/api.js
+++ b/application/components/github/api.js
@@ -100,17 +100,20 @@ export class API extends EventEmitter {
url.search = new URLSearchParams({ branch }).toString()
}
- const { status, data } = await this._request(url.toString())
-
- if (status === 400) {
- console.error('Failed to load keymap and layout from github')
- return data
- }
+ try {
+ const { data } = await this._request(url.toString())
+ const defaultLayout = data.info.layouts.default || data.info.layouts[Object.keys(data.info.layouts)[0]]
+ return {
+ layout: defaultLayout.layout,
+ keymap: data.keymap
+ }
+ } catch (err) {
+ if (err.response?.status === 400) {
+ console.error('Failed to load keymap and layout from github', err.response.data)
+ this.emit('repo-validation-error', err.response.data)
+ }
- const defaultLayout = data.info.layouts.default || data.info.layouts[Object.keys(data.info.layouts)[0]]
- return {
- layout: defaultLayout.layout,
- keymap: data.keymap
+ throw err
}
}