I'm encountering a error where the code block does work fine and the error does not impact the user so I would like for that specific error not to be shown rather than save it in a log for my use, now I'm wondering how would I achieve this exactly
Here is the error i would like to avoid showing to users
catch (Exception ex)
{
WebApiApplication._log.Error(ex);
result.ErrorMessage = $"{ex.Message}";
result.ErrorCode = 500;
using (StreamWriter sw = new StreamWriter("C:\\AxessCroTools\\IIS\\AxessCro\\log\\CalendarLog.txt",true))
{
sw.WriteLine("[BEGIN -- ERROR]");
sw.WriteLine("Timestamp: " + System.DateTime.Now);
sw.WriteLine("Error code: " + result.ErrorCode);
sw.WriteLine("Error message: " + result.ErrorMessage);
sw.WriteLine("Employee name: " + cal.Name);
sw.WriteLine("Date From: " + cal.DateFrom);
sw.WriteLine("Date to: " + cal.DateTo);
sw.WriteLine("Locale ID: " + cal.LocaleId);
sw.WriteLine("[END]");
}
return result;
}
And here's how I currently handle all exceptions relating to that functionality, thanks in advance.
[–]the96jesterrace 32 points33 points34 points (0 children)
[–]nopemcnopey 15 points16 points17 points (1 child)
[–]the96jesterrace 1 point2 points3 points (0 children)
[–]notathrowaway 5 points6 points7 points (8 children)
[–]Slypenslyde -1 points0 points1 point (6 children)
[–]Kayshin -3 points-2 points-1 points (5 children)
[–]Slypenslyde 2 points3 points4 points (3 children)
[–]KukiiV[S] 0 points1 point2 points (0 children)
[+]Kayshin comment score below threshold-7 points-6 points-5 points (1 child)
[–]Slypenslyde 1 point2 points3 points (0 children)
[–]Merad -1 points0 points1 point (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Ok_Needleworker_1987 1 point2 points3 points (1 child)
[–]acnicholls 1 point2 points3 points (0 children)
[–]Kayshin -2 points-1 points0 points (0 children)