mirror of https://github.com/Radarr/Radarr
constraint failed exceptions are translated to 409 conflict status codes.
This commit is contained in:
parent
be3ec7ddb8
commit
bbb69a1dc7
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Data.SQLite;
|
||||
using FluentValidation;
|
||||
using NLog;
|
||||
using Nancy;
|
||||
|
@ -48,6 +49,21 @@ namespace NzbDrone.Api.ErrorManagement
|
|||
}.AsResponse((HttpStatusCode)clientException.StatusCode);
|
||||
}
|
||||
|
||||
|
||||
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
||||
{
|
||||
var sqLiteException = exception as SQLiteException;
|
||||
|
||||
if (sqLiteException != null)
|
||||
{
|
||||
if (sqLiteException.Message.Contains("constraint failed"))
|
||||
return new ErrorModel
|
||||
{
|
||||
Message = exception.Message,
|
||||
}.AsResponse(HttpStatusCode.Conflict);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.FatalException("Request Failed", exception);
|
||||
|
||||
return new ErrorModel
|
||||
|
|
|
@ -68,6 +68,11 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Sqlite\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
|
||||
|
|
|
@ -79,6 +79,10 @@
|
|||
message.message = xmlHttpRequest.responseJSON.message;
|
||||
}
|
||||
|
||||
if (xmlHttpRequest.status === 409) {
|
||||
message.message = xmlHttpRequest.responseJSON.message;
|
||||
}
|
||||
|
||||
else {
|
||||
message.message = '[{0}] {1} : {2}'.format(ajaxOptions.type, xmlHttpRequest.statusText, ajaxOptions.url);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue