feat: simple failed request handling (#474)

When a movie or series is added with radarr or sonarr, if it fails, this changes the media state to
unknown and sends a notification to admins. Client side this will look like a failed state along
with a retry button that will delete the request and re-queue it.
This commit is contained in:
johnpyp
2020-12-24 19:53:32 -05:00
committed by GitHub
parent ed94a0f335
commit 02969d5426
12 changed files with 296 additions and 47 deletions

View File

@@ -116,7 +116,7 @@ class SonarrAPI {
}
}
public async addSeries(options: AddSeriesOptions): Promise<SonarrSeries> {
public async addSeries(options: AddSeriesOptions): Promise<boolean> {
try {
const series = await this.getSeriesByTvdbId(options.tvdbid);
@@ -147,9 +147,10 @@ class SonarrAPI {
label: 'Sonarr',
options,
});
return false;
}
return newSeriesResponse.data;
return true;
}
const createdSeriesResponse = await this.axios.post<SonarrSeries>(
@@ -188,16 +189,18 @@ class SonarrAPI {
label: 'Sonarr',
options,
});
return false;
}
return createdSeriesResponse.data;
return true;
} catch (e) {
logger.error('Something went wrong adding a series to Sonarr', {
label: 'Sonarr API',
errorMessage: e.message,
error: e,
response: e?.response?.data,
});
throw new Error('Failed to add series');
return false;
}
}