refactor(Document-, EnvelopeController): Globale try-catch-Anweisungen entfernen

This commit is contained in:
tekh 2025-08-21 11:03:41 +02:00
parent 730a318b56
commit 903e4678ed
2 changed files with 80 additions and 120 deletions

View File

@ -29,8 +29,6 @@ public class DocumentController : BaseController
[Obsolete("Use MediatR")]
[NonAction]
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
{
try
{
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
@ -45,19 +43,11 @@ public class DocumentController : BaseController
// Return the document as bytes
return File(bytes, "application/octet-stream");
}
catch(Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Open(string envelopeKey)
{
try
{
var authSignature = this.GetAuthReceiverSignature();
@ -72,10 +62,4 @@ public class DocumentController : BaseController
return Ok(new object());
}
catch(Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}

View File

@ -46,8 +46,6 @@ public class EnvelopeController : BaseController
[NonAction]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Get([FromRoute] string envelopeKey)
{
try
{
envelopeKey = _urlEncoder.Encode(envelopeKey);
@ -64,19 +62,11 @@ public class EnvelopeController : BaseController
_logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
return Json(response);
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")]
[Obsolete("Use MediatR")]
public async Task<IActionResult> Update(string envelopeKey, int index)
{
try
{
envelopeKey = _urlEncoder.Encode(envelopeKey);
@ -111,24 +101,16 @@ public class EnvelopeController : BaseController
return Ok(new object());
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("reject")]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public async Task<IActionResult> Reject([FromBody] string? reason = null)
{
try
{
var signature = this.GetAuthReceiverSignature();
var uuid = this.GetAuthEnvelopeUuid();
var mail = this.GetAuthReceiverMail();
if(uuid is null || signature is null || mail is null)
if (uuid is null || signature is null || mail is null)
{
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
message: @$"Unauthorized POST request in api\envelope\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
@ -152,10 +134,4 @@ public class EnvelopeController : BaseController
return this.ViewInnerServiceError();
});
}
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}