C
C#2y ago
Bujju

✅ Exception message not working

I have this code for an exception:
public class WebhookExecutionFailedException : Exception
{
internal WebhookExecutionFailedException(string message, WebhookError error, HttpResponseMesage response) : base(message)
{
ErrorMessage = error.Message;
ErrorCode = error.Code;
Response = response;
}

public string ErrorMessage { get; private set; }

public int ErrorCode { get; private set; }

public HttpResponseMessage { get; private set; }
}
public class WebhookExecutionFailedException : Exception
{
internal WebhookExecutionFailedException(string message, WebhookError error, HttpResponseMesage response) : base(message)
{
ErrorMessage = error.Message;
ErrorCode = error.Code;
Response = response;
}

public string ErrorMessage { get; private set; }

public int ErrorCode { get; private set; }

public HttpResponseMessage { get; private set; }
}
And this code for throwing the exception:
throw new WebhookExecutionFailedException(error.Message, error, response);
throw new WebhookExecutionFailedException(error.Message, error, response);
But when the exception is thrown, the message is "Exception of type 'DiscordIntegration.Exceptions.WebhookExecutionFailedException' was thrown.'" instead of the value of error.Message.
3 Replies
phaseshift
phaseshift2y ago
You're probably confusing logging of an exception, with the exception message Also why would you have ErrorMessage property when the base class already has basically that
Bujju
BujjuOP2y ago
Bujju
BujjuOP2y ago
Nevermind I found the issue
Want results from more Discord servers?
Add your server