From 82baca1bfdedef06d264bfcd097be9af1b7244cd Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Fri, 6 Oct 2023 12:47:20 +0300 Subject: [PATCH] Controllers/Common: return JSON response with error --- ELT.Client/Models/Common/Response.cs | 6 ++++++ ELT/Controllers/CommonController.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 ELT.Client/Models/Common/Response.cs diff --git a/ELT.Client/Models/Common/Response.cs b/ELT.Client/Models/Common/Response.cs new file mode 100644 index 0000000..bfb1fbc --- /dev/null +++ b/ELT.Client/Models/Common/Response.cs @@ -0,0 +1,6 @@ +namespace ELT.Client.Models.Common; + +public class ErrorResponse +{ + public string Error { get; set; } +} \ No newline at end of file diff --git a/ELT/Controllers/CommonController.cs b/ELT/Controllers/CommonController.cs index 901b280..42dbf8a 100644 --- a/ELT/Controllers/CommonController.cs +++ b/ELT/Controllers/CommonController.cs @@ -84,7 +84,7 @@ public class CommonController : ControllerBase } catch (Exception e) { - return StatusCode(500, e.Message); + return StatusCode(500, new ErrorResponse { Error = e.Message }); } } @@ -119,7 +119,7 @@ public class CommonController : ControllerBase } catch (Exception e) { - return StatusCode(500, e.Message); + return StatusCode(500, new ErrorResponse { Error = e.Message }); } } } \ No newline at end of file