C#C
C#4y 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; }
}

And this code for throwing the exception:

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.
Was this page helpful?