diff --git a/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs b/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs
index 236bcc8df..c7f5cbd36 100644
--- a/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs
+++ b/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs
@@ -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
diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj
index 939dcd9ef..9569bf6f3 100644
--- a/src/NzbDrone.Api/NzbDrone.Api.csproj
+++ b/src/NzbDrone.Api/NzbDrone.Api.csproj
@@ -68,6 +68,11 @@
+
+
+ False
+ ..\Libraries\Sqlite\System.Data.SQLite.dll
+
diff --git a/src/UI/Instrumentation/ErrorHandler.js b/src/UI/Instrumentation/ErrorHandler.js
index 0de3744dd..d74eafc22 100644
--- a/src/UI/Instrumentation/ErrorHandler.js
+++ b/src/UI/Instrumentation/ErrorHandler.js
@@ -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);
}