dev #8

Merged
rajukottedi merged 2 commits from dev into prod 2026-02-16 12:23:38 +05:30
3 changed files with 6 additions and 6 deletions
Showing only changes of commit 4b968099ad - Show all commits

View File

@ -59,7 +59,7 @@ namespace PortBlog.API.Controllers
catch (Exception ex) catch (Exception ex)
{ {
logger.LogCritical(ex, "Exception while sending OTP for {ToEmail}.", messageSendDto.ToEmail); logger.LogCritical(ex, "Exception while sending OTP for {ToEmail}.", messageSendDto.ToEmail);
return StatusCode(500, "A problem happened while handling your request."); return StatusCode(500, ex.Message);
} }
} }

View File

@ -262,8 +262,8 @@ namespace PortBlog.API.Controllers
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogCritical($"Exception while sending message from {message.Name}.", ex); _logger.LogCritical(ex, "Exception while sending message from {Name}.", message.Name);
return StatusCode(500, "A problem happened while handling your request."); return StatusCode(500, ex.Message);
} }
} }
} }

View File

@ -67,14 +67,14 @@ namespace PortBlog.API.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
// Log full exception and persist failed message. Do not rethrow to avoid causing a 500 from OTP generation // Log full exception and persist failed message.
logger.LogCritical(ex, "Exception while sending mail from {FromEmail} ({Name}).", messageSendDto.FromEmail, messageSendDto.Name); logger.LogCritical(ex, "Exception while sending mail from {FromEmail} ({Name}).", messageSendDto.FromEmail, messageSendDto.Name);
messageSendDto.SentStatus = (int)MailConstants.MailStatus.Failed; messageSendDto.SentStatus = (int)MailConstants.MailStatus.Failed;
mailRepository.AddMessage(messageEntity); mailRepository.AddMessage(messageEntity);
await mailRepository.SaveChangesAsync(); await mailRepository.SaveChangesAsync();
// swallow the exception so OTP generation continues; caller can inspect delivery status via message logs // Throw a descriptive exception so callers can return an error message to the client.
return; throw new InvalidOperationException($"Failed to send email to '{messageSendDto.ToEmail}'. See inner exception for details.", ex);
} }
} }
} }