1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-24 03:33:31 +01:00

Fixed: Better error messaging if you try to import an invalid Custom Format

This commit is contained in:
Robert Dailey 2022-09-22 11:44:45 -05:00 committed by GitHub
parent e742eb49d7
commit 51eeb4ee0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
@ -47,7 +48,16 @@ namespace Sonarr.Api.V3.CustomFormats
private static ICustomFormatSpecification MapSpecification(CustomFormatSpecificationSchema resource, List<ICustomFormatSpecification> specifications)
{
var type = specifications.SingleOrDefault(x => x.GetType().Name == resource.Implementation).GetType();
var matchingSpec =
specifications.SingleOrDefault(x => x.GetType().Name == resource.Implementation);
if (matchingSpec is null)
{
throw new ArgumentException(
$"{resource.Implementation} is not a valid specification implementation");
}
var type = matchingSpec.GetType();
// Finding the exact current specification isn't possible given the dynamic nature of them and the possibility that multiple
// of the same type exist within the same format. Passing in null is safe as long as there never exists a specification that