Skip to content

Commit 25e78fb

Browse files
committed
chore: adding error handle
1 parent 2ea89f2 commit 25e78fb

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

dist/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13487,12 +13487,16 @@ class Github {
1348713487
return envs;
1348813488
}
1348913489
static createGithubConnection(apiToken) {
13490-
return axios_1.default.create({
13490+
const config = axios_1.default.create({
1349113491
baseURL: 'https://api.github.com',
1349213492
headers: {
1349313493
Authorization: `Bearer ${apiToken}`,
1349413494
},
1349513495
});
13496+
config.interceptors.response.use(null, ({ response }) => {
13497+
throw new Error(JSON.stringify(response?.data, null, 2));
13498+
});
13499+
return config;
1349613500
}
1349713501
}
1349813502
exports.Github = Github;

scr/services/github.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ export class Github {
4949
}
5050

5151
private static createGithubConnection(apiToken: string) {
52-
return axios.create({
52+
const config = axios.create({
5353
baseURL: 'https://api.github.com',
5454
headers: {
5555
Authorization: `Bearer ${apiToken}`,
5656
},
5757
});
58+
config.interceptors.response.use(null, ({ response }) => {
59+
throw new Error(JSON.stringify(response?.data, null, 2));
60+
});
61+
62+
return config;
5863
}
5964
}

0 commit comments

Comments
 (0)