Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java异常捕获/抛出_Java_Exception Handling - Fatal编程技术网

Java异常捕获/抛出

Java异常捕获/抛出,java,exception-handling,Java,Exception Handling,我有以下课程: BusinessException.java(是需要捕获异常并抛出它的主要异常类) BusinessExceptionInfo.java public class BusinessException { protected ExceptionResponse exceptionResponse; protected String message; // getters and setters for these properties } public

我有以下课程:

BusinessException.java(是需要捕获异常并抛出它的主要异常类)

BusinessExceptionInfo.java

public class BusinessException {

    protected ExceptionResponse exceptionResponse;
    protected String message;

    // getters and setters for these properties
}
public class ErrorResponseItem {

    protected String defaultErrorDescription;
    protected List<String> descriptionVariables;
    protected String errorCode;
    protected SourceSystemFault sourceSystemFault;

// getter and setter methods
}

// SourceSystemFault.java
public class SourceSystemFault {

    protected List<String> calloutParameters;
    protected String errorCode;
    protected String errorDescription;
    protected String operationName;
    protected String serviceName;
    protected String system;
}
ExceptionResponse.java(此类保存异常消息和堆栈跟踪。此类需要使用来自异常的值填充)


如何捕获并抛出BusinessException。我是个新手,需要帮助。

你能解释一下你想要实现什么吗?尝试在soap Web服务中抛出业务异常你读过Java异常教程吗?要捕获的异常在哪里?当您遇到异常时,您希望发生什么?
public class ExceptionResponse {

    protected String exceptionClass;
    protected String exceptionMessage;
    protected List<ErrorResponseItem> errorResponseItems;
    protected String stackTrace;

    // getters and setters for these properties
}
public class ErrorResponseItem {

    protected String defaultErrorDescription;
    protected List<String> descriptionVariables;
    protected String errorCode;
    protected SourceSystemFault sourceSystemFault;

// getter and setter methods
}

// SourceSystemFault.java
public class SourceSystemFault {

    protected List<String> calloutParameters;
    protected String errorCode;
    protected String errorDescription;
    protected String operationName;
    protected String serviceName;
    protected String system;
}
public MyResponse myMethod(MyRequest req)
            throws BusinessException {
}