Greetings Programs!
I've got a method with a try/catch in which I throw a UserFriendlyException.
I'm going to be calling it from a hangfire job now within a foreach loop and I was wondering if there is a way to log the exception without throwing it so it doesn't stop the job?
Thanks,
Wg
5 Answer(s)
-
0
@wizgod, UserFriendlyException is designed to return an error message to the client. If you're throwing it in a Hangfire job there is no client, use standard exception handling or simply log the error.
-
0
simply log the error.
Just log it without throwing an exception.
try { //you code } catch (Exception exception) { _logger.Fatal(ex.ToString()); // Just log it without throwing an exception. }
-
0
Hi @maliming,
I am using Castle.Core.Logging and injecting ILogger for the _ logger instance, is this correct?
Thanks,
Wg
-
0
hi @wizgod
see https://aspnetboilerplate.com/Pages/Documents/Logging
-
0
This issue is closed because of no recent activity. Please create a new issue if you are still having this problem.