mirror of
https://github.com/Radarr/Radarr
synced 2025-02-28 00:45:50 +00:00
Better logging if SQLite exception is thrown during API call
This commit is contained in:
parent
64bbba90b0
commit
1ed45625df
1 changed files with 9 additions and 5 deletions
|
@ -50,11 +50,11 @@ public Response HandleException(NancyContext context, Exception exception)
|
||||||
}.AsResponse((HttpStatusCode)clientException.StatusCode);
|
}.AsResponse((HttpStatusCode)clientException.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
var sqLiteException = exception as SQLiteException;
|
||||||
{
|
|
||||||
var sqLiteException = exception as SQLiteException;
|
|
||||||
|
|
||||||
if (sqLiteException != null)
|
if (sqLiteException != null)
|
||||||
|
{
|
||||||
|
if (context.Request.Method == "PUT" || context.Request.Method == "POST")
|
||||||
{
|
{
|
||||||
if (sqLiteException.Message.Contains("constraint failed"))
|
if (sqLiteException.Message.Contains("constraint failed"))
|
||||||
return new ErrorModel
|
return new ErrorModel
|
||||||
|
@ -62,8 +62,12 @@ public Response HandleException(NancyContext context, Exception exception)
|
||||||
Message = exception.Message,
|
Message = exception.Message,
|
||||||
}.AsResponse(HttpStatusCode.Conflict);
|
}.AsResponse(HttpStatusCode.Conflict);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
var sqlErrorMessage = String.Format("[{0} {1}?{2}]", context.Request.Method, context.Request.Path, context.Request.Query);
|
||||||
|
|
||||||
|
_logger.ErrorException(sqlErrorMessage, sqLiteException);
|
||||||
|
}
|
||||||
|
|
||||||
_logger.FatalException("Request Failed", exception);
|
_logger.FatalException("Request Failed", exception);
|
||||||
|
|
||||||
return new ErrorModel
|
return new ErrorModel
|
||||||
|
|
Loading…
Reference in a new issue