Custom Web servcie Exception

2
I know this post is old, but this is still being queried on our side. Will there ever be an option for "Custom Errors" from an exposed webservice? i.e. throw a "MyProjectException" instead of the FaultException? Or at least just define a different error than a FaultException?
asked
3 answers
2

Why do you want to create a new exception type? Just do something like this:

throw new WebserviceException("your error message");
answered
2

I hope you could guide me a bit here, I don't understand 100%.

First of all, I created the Java class as shown below :

import com.mendix.modules.webservices.WebserviceException;
public class MyProjectException extends WebserviceException {

public MyProjectException(String faultCode, String faultString) {
    super(faultCode, faultString);
    // TODO Auto-generated constructor stub
}

public MyProjectException(String faultCode, String faultString, Throwable cause) {
    super(faultCode, faultString, cause);
    // TODO Auto-generated constructor stub
}

}

Then in my java action I throw the MyProjectException, like so :

public Boolean executeAction() throws Exception
{
    // BEGIN USER CODE
    throw new MyProjectException("My Project Exception", error);
    // END USER CODE
}

So I add the above mentioned Java action to a Microflow and expose it as a Webservice. When I execute the operation in my client, I still get a FaultException, not a MyProjectException.

Is this what you meant with "extend webserviceexception"?

answered
1

Just extend your exception from WebserviceException

answered