aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/components/github/api.js
diff options
context:
space:
mode:
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
}
}