Skip to content

Commit d285c01

Browse files
committed
Explicitly handle errors when testing connection to codedx
1 parent 57e39c7 commit d285c01

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

codedx.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ class CodeDxApiClient {
6262
}
6363

6464
async testConnection() {
65-
const response = await this.anonymousHttp.get('/x/system-info').catch(rethrowError)
65+
const response = await this.anonymousHttp.get('/x/system-info').catch(e => {
66+
if (axios.isAxiosError(e) && e.response) {
67+
throw new Error(`Expected OK response, got ${e.response.status}. Is this a Code Dx instance?`)
68+
} else {
69+
throw e
70+
}
71+
})
6672

6773
if (typeof response.data != 'object') {
6874
throw new Error(`Expected JSON Object response, got ${typeof response.data}. Is this a Code Dx instance?`)

0 commit comments

Comments
 (0)