I need to create an exception in Java that operates in the same manner as the following C# one.
public class ResponseException : Exception
{
internal ResponseException(int statusCode, String StatusCodeDescription, String request, String response)
: base("Returned an error status code " + statusCode.ToString() + " (" + StatusCodeDescription + ") " + response)
{
this.StatusCode = statusCode;
this.StatusCodeDescription = StatusCodeDescription;
this.Request = request;
this.Response = response;
}
public int StatusCode { get; set; }
public String StatusCodeDescription { get; set; }
public String Request { get; set; }
public String Response { get; set; }
}
Currently I can not find an example of a Java exception that works in such a way. The exception above is called in this manner
throw new ResponseException(((int)response[1]),
((String)response[2]), url, ((String)response[0]));
I read through the following threads but they didn't provide much insight on how I would go about this, or if it is even possible.
How to create a custom exception type in Java?
How to create custom exceptions in Java?
http://www.java-forums.org/java-lang/7699-how-create-your-own-exception-class.html