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

@@ -76,7 +76,7 @@ class RadarrAPI {
}
};
public addMovie = async (options: RadarrMovieOptions): Promise<void> => {
public addMovie = async (options: RadarrMovieOptions): Promise<boolean> => {
try {
const response = await this.axios.post<RadarrMovie>(`/movie`, {
title: options.title,
@@ -104,7 +104,9 @@ class RadarrAPI {
label: 'Radarr',
options,
});
return false;
}
return true;
} catch (e) {
logger.error(
'Failed to add movie to Radarr. This might happen if the movie already exists, in which case you can safely ignore this error.',
@@ -112,8 +114,13 @@ class RadarrAPI {
label: 'Radarr',
errorMessage: e.message,
options,
response: e?.response?.data,
}
);
if (e?.response?.data?.[0]?.errorCode === 'MovieExistsValidator') {
return true;
}
return false;
}
};