Remove exception handler

This commit is contained in:
crobibero 2020-04-21 07:55:57 -06:00
parent c5d709f77e
commit 04119c0d40

View file

@ -1,6 +1,5 @@
#nullable enable #nullable enable
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Threading; using System.Threading;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
@ -45,20 +44,13 @@ namespace Jellyfin.Api.Controllers
[FromQuery] [Required] string userId, [FromQuery] [Required] string userId,
[FromQuery] [Required] string client) [FromQuery] [Required] string client)
{ {
try var result = _displayPreferencesRepository.GetDisplayPreferences(displayPreferencesId, userId, client);
if (result == null)
{ {
var result = _displayPreferencesRepository.GetDisplayPreferences(displayPreferencesId, userId, client); return NotFound();
if (result == null) }
{
return NotFound();
}
return Ok(result); return Ok(result);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
} }
/// <summary> /// <summary>
@ -80,30 +72,23 @@ namespace Jellyfin.Api.Controllers
[FromQuery, BindRequired] string client, [FromQuery, BindRequired] string client,
[FromBody, BindRequired] DisplayPreferences displayPreferences) [FromBody, BindRequired] DisplayPreferences displayPreferences)
{ {
try if (!ModelState.IsValid)
{ {
if (!ModelState.IsValid) return BadRequest(ModelState);
{
return BadRequest(ModelState);
}
if (displayPreferencesId == null)
{
// do nothing.
}
_displayPreferencesRepository.SaveDisplayPreferences(
displayPreferences,
userId,
client,
CancellationToken.None);
return Ok();
} }
catch (Exception e)
if (displayPreferencesId == null)
{ {
return StatusCode(StatusCodes.Status500InternalServerError, e.Message); // do nothing.
} }
_displayPreferencesRepository.SaveDisplayPreferences(
displayPreferences,
userId,
client,
CancellationToken.None);
return Ok();
} }
} }
} }