diff --git a/Controllers/CategoryController.cs b/Controllers/CategoryController.cs index 99f16a1..0dc6bcf 100644 --- a/Controllers/CategoryController.cs +++ b/Controllers/CategoryController.cs @@ -10,7 +10,7 @@ namespace Blog.Controllers { [ApiController] - public class CategoryController: ControllerBase + public class CategoryController : ControllerBase { [HttpGet("v1/categories")] public async Task GetAsync( @@ -25,14 +25,14 @@ public async Task GetAsync( entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1); return GetCategories(context); }); - + return Ok(new ResultVM>(categories)); } - catch + catch (Exception ex) { - return StatusCode(500, new ResultVM>("05x06 - Falha interna no Servidor")); + return StatusCode(500, new ResultVM>("05x06 - Falha interna no Servidor \n" + ex.Message + "\n" + ex.ToString)); } } @@ -57,13 +57,13 @@ public async Task GetByIdAsync( return Ok(new ResultVM(category)); } - catch(DbUpdateException ex) + catch (DbUpdateException ex) { return StatusCode(500, new ResultVM("05x07 - Não foi possivel incluir categoria")); } - catch (Exception ex) + catch (Exception ex) { - return StatusCode(500, new ResultVM( "05x08 - Falha interna no Servidor")); + return StatusCode(500, new ResultVM("05x08 - Falha interna no Servidor")); } } @@ -77,25 +77,25 @@ public async Task PostAsync( try { - var category = new Category - { - Id=0, - Name=model.Name, - Slug=model.Slug.ToLower() + var category = new Category + { + Id = 0, + Name = model.Name, + Slug = model.Slug.ToLower() }; await context.Categories.AddAsync(category); await context.SaveChangesAsync(); return Created($"v1/categories/{category.Id}", new ResultVM(category)); } - catch(DbUpdateException ex) + catch (DbUpdateException ex) { return StatusCode(500, new ResultVM("05x09 - Não foi possivel incluir categoria")); } - - catch + + catch (Exception ex) { - return StatusCode(500, new ResultVM("05x10 - Falha interna no Servidor")); + return StatusCode(500, new ResultVM("05x10 - Falha interna no Servidor\n" + ex.Message + "\n" + ex.ToString)); } @@ -126,7 +126,7 @@ public async Task PutAsync( return StatusCode(500, new ResultVM("05x12 - Não foi possivel incluir categoria")); } - catch + catch { return StatusCode(500, new ResultVM("05x13 - Falha interna no Servidor")); } @@ -154,7 +154,7 @@ public async Task DeleteAsync( return StatusCode(500, new ResultVM("05x14 - Não foi possivel incluir categoria")); } - catch + catch { return StatusCode(500, new ResultVM("05x15 - Falha interna no Servidor")); }