Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.

Commit 8f2beef

Browse files
author
yacut
committed
catch request errors
1 parent 9ed54f0 commit 8f2beef

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class GrafanaSync {
165165
},
166166
json: true,
167167
uri: `${this.grafanaUri}/api/orgs/name/${name}`,
168-
});
168+
}).catch((err) => err.response);
169169
this.logger.debug({ name, response }, "Got grafana organisation by name.");
170170
if (!response.id) {
171171
throw new Error(`Could not get grafana orgatiosation by name ${name}`);
@@ -186,7 +186,7 @@ class GrafanaSync {
186186
},
187187
json: true,
188188
uri: `${this.grafanaUri}/api/orgs/${orgId}/users`,
189-
});
189+
}).catch((err) => err.response);
190190
this.logger.debug({ orgId, response }, "Got grafana organisation users.");
191191
if (response.constructor !== Array) {
192192
return [];
@@ -210,7 +210,7 @@ class GrafanaSync {
210210
},
211211
json: true,
212212
uri: `${this.grafanaUri}/api/users/lookup?loginOrEmail=${email}`,
213-
});
213+
}).catch((err) => err.response);
214214
this.logger.debug({ email, response }, "Got grafana user id.");
215215
if (response.constructor !== Object) {
216216
throw new Error(`Could not get user by email: ${email}`);
@@ -230,7 +230,7 @@ class GrafanaSync {
230230
},
231231
json: true,
232232
uri: `${this.grafanaUri}/api/users/${userId}/orgs`,
233-
});
233+
}).catch((err) => err.response);
234234
this.logger.debug({ userId, email, response }, "Got grafana user.");
235235
if (response.constructor !== Array) {
236236
throw new Error(`Could not get user: ${userId}`);
@@ -263,7 +263,7 @@ class GrafanaSync {
263263
},
264264
json: true,
265265
uri: `${this.grafanaUri}/api/orgs/${orgId}/users`,
266-
});
266+
}).catch((err) => err.response);
267267
this.logger.debug({ orgId, email, role, response }, "Created grafana organisation user.");
268268
return response;
269269
} catch (e) {
@@ -285,7 +285,7 @@ class GrafanaSync {
285285
},
286286
json: true,
287287
uri: `${this.grafanaUri}/api/orgs/${orgId}/users/${userId}`,
288-
});
288+
}).catch((err) => err.response);
289289
this.logger.debug({ orgId, userId, role, response }, "Updated grafana user.");
290290
return response;
291291
} catch (e) {
@@ -308,7 +308,7 @@ class GrafanaSync {
308308
},
309309
json: true,
310310
uri: `${this.grafanaUri}/api/orgs/${orgId}/users/${userId}`,
311-
});
311+
}).catch((err) => err.response);
312312
this.logger.debug({ orgId, userId, response }, "Delete grafana user.");
313313
return response;
314314
} catch (e) {

0 commit comments

Comments
 (0)