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")] [Obsolete("Use MediatR")]
[NonAction] [NonAction]
public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index) public async Task<IActionResult> Get([FromRoute] string envelopeKey, [FromQuery] int index)
{
try
{ {
// Validate Envelope Key and load envelope // Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey); envelopeService.EnsureValidEnvelopeKey(envelopeKey);
@ -45,19 +43,11 @@ public class DocumentController : BaseController
// Return the document as bytes // Return the document as bytes
return File(bytes, "application/octet-stream"); return File(bytes, "application/octet-stream");
} }
catch(Exception ex)
{
_logger.LogError(ex, "{Message}", ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)] [Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")] [HttpPost("{envelopeKey}")]
[Obsolete("Use MediatR")] [Obsolete("Use MediatR")]
public async Task<IActionResult> Open(string envelopeKey) public async Task<IActionResult> Open(string envelopeKey)
{
try
{ {
var authSignature = this.GetAuthReceiverSignature(); var authSignature = this.GetAuthReceiverSignature();
@ -72,10 +62,4 @@ public class DocumentController : BaseController
return Ok(new object()); 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] [NonAction]
[Obsolete("Use MediatR")] [Obsolete("Use MediatR")]
public async Task<IActionResult> Get([FromRoute] string envelopeKey) public async Task<IActionResult> Get([FromRoute] string envelopeKey)
{
try
{ {
envelopeKey = _urlEncoder.Encode(envelopeKey); 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); _logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
return Json(response); return Json(response);
} }
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)] [Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("{envelopeKey}")] [HttpPost("{envelopeKey}")]
[Obsolete("Use MediatR")] [Obsolete("Use MediatR")]
public async Task<IActionResult> Update(string envelopeKey, int index) public async Task<IActionResult> Update(string envelopeKey, int index)
{
try
{ {
envelopeKey = _urlEncoder.Encode(envelopeKey); envelopeKey = _urlEncoder.Encode(envelopeKey);
@ -111,19 +101,11 @@ public class EnvelopeController : BaseController
return Ok(new object()); return Ok(new object());
} }
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
[Authorize(Roles = ReceiverRole.FullyAuth)] [Authorize(Roles = ReceiverRole.FullyAuth)]
[HttpPost("reject")] [HttpPost("reject")]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")] [Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public async Task<IActionResult> Reject([FromBody] string? reason = null) public async Task<IActionResult> Reject([FromBody] string? reason = null)
{
try
{ {
var signature = this.GetAuthReceiverSignature(); var signature = this.GetAuthReceiverSignature();
var uuid = this.GetAuthEnvelopeUuid(); var uuid = this.GetAuthEnvelopeUuid();
@ -152,10 +134,4 @@ public class EnvelopeController : BaseController
return this.ViewInnerServiceError(); return this.ViewInnerServiceError();
}); });
} }
catch (Exception e)
{
_logger.LogError(e, "{Message}", e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
} }