diff --git a/plugins/newrelic/src/api/index.ts b/plugins/newrelic/src/api/index.ts index eb94acdbd1..d76a87875c 100644 --- a/plugins/newrelic/src/api/index.ts +++ b/plugins/newrelic/src/api/index.ts @@ -84,10 +84,20 @@ export class NewRelicClient implements NewRelicApi { async getApplications(): Promise { const url = await this.getApiUrl('apm', 'applications.json'); const response = await fetch(url); - const responseJson = await response.json(); + let responseJson; + + try { + responseJson = await response.json(); + } catch (e) { + responseJson = { applications: [] }; + } if (response.status !== 200) { - throw new Error(responseJson?.error?.title || response.statusText); + throw new Error( + `Error communicating with New Relic: ${ + responseJson?.error?.title || response.statusText + }`, + ); } return responseJson;