diff --git a/src/Humans.Web/Controllers/ProfileController.cs b/src/Humans.Web/Controllers/ProfileController.cs index 951703ed..b6434120 100644 --- a/src/Humans.Web/Controllers/ProfileController.cs +++ b/src/Humans.Web/Controllers/ProfileController.cs @@ -567,7 +567,7 @@ await _emailService.SendEmailVerificationAsync( } catch (ValidationException ex) { - _logger.LogWarning(ex, "Failed to add email address for user {UserId}", user.Id); + _logger.LogWarning("Rejected email add for user {UserId}: {Reason}", user.Id, ex.Message); ModelState.AddModelError(nameof(model.NewEmail), ex.Message); return View(nameof(Emails), await BuildEmailsViewModelAsync(user)); } @@ -971,12 +971,20 @@ public async Task DownloadData() [ResponseCache(Duration = 3600, Location = ResponseCacheLocation.Client)] public async Task Picture(Guid id, CancellationToken ct) { - var (data, contentType) = await _profileService.GetProfilePictureAsync(id, ct); + try + { + var (data, contentType) = await _profileService.GetProfilePictureAsync(id, ct); - if (data is null || string.IsNullOrEmpty(contentType)) - return NotFound(); + if (data is null || string.IsNullOrEmpty(contentType)) + return NotFound(); - return File(data, contentType); + return File(data, contentType); + } + catch (OperationCanceledException) when (ct.IsCancellationRequested) + { + _logger.LogWarning("Profile picture request for {ProfileId} was cancelled by the client", id); + return StatusCode(499); + } } // ─── View Another Profile ──────────────────────────────────────── diff --git a/src/Humans.Web/Controllers/ShiftAdminController.cs b/src/Humans.Web/Controllers/ShiftAdminController.cs index ef4472d2..257895d7 100644 --- a/src/Humans.Web/Controllers/ShiftAdminController.cs +++ b/src/Humans.Web/Controllers/ShiftAdminController.cs @@ -479,7 +479,7 @@ public async Task DeleteShift(string slug, Guid shiftId) } catch (InvalidOperationException ex) { - _logger.LogWarning(ex, "Failed to delete shift {ShiftId} in team {Slug}", shiftId, slug); + _logger.LogWarning("Rejected shift delete for shift {ShiftId} in team {Slug}: {Reason}", shiftId, slug, ex.Message); SetError(ex.Message); }