package org.opendaylight.netconf.sal.restconf.impl;
import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.Collection;
* The underlying exception cause.
*/
public RestconfDocumentedException(String message, ErrorType errorType, ErrorTag errorTag, Throwable cause) {
- this(cause, new RestconfError(errorType, errorTag, message, null, RestconfError.toErrorInfo(cause)));
+ this(cause, new RestconfError(errorType, errorTag, message, null, Throwables.getStackTraceAsString(cause)));
}
/**
*/
public RestconfDocumentedException(String message, Throwable cause) {
this(cause, new RestconfError(RestconfError.ErrorType.APPLICATION, RestconfError.ErrorTag.OPERATION_FAILED,
- message, null, RestconfError.toErrorInfo(cause)));
+ message, null, Throwables.getStackTraceAsString(cause)));
}
/**
package org.opendaylight.netconf.sal.restconf.impl;
import com.google.common.base.Preconditions;
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import com.google.common.base.Throwables;
import org.opendaylight.yangtools.yang.common.RpcError;
/**
private final String errorInfo;
private final String errorAppTag;
private final String errorMessage;
-
// TODO: Add in the error-path concept as defined in the ietf draft.
- static String toErrorInfo(Throwable cause) {
- StringWriter writer = new StringWriter();
- cause.printStackTrace(new PrintWriter(writer));
- return writer.toString();
- }
-
/**
* Constructs a RestConfError
*
String errorInfo = null;
if (rpcError.getInfo() == null) {
if (rpcError.getCause() != null) {
- errorInfo = toErrorInfo(rpcError.getCause());
+ errorInfo = Throwables.getStackTraceAsString(rpcError.getCause());
} else if (rpcError.getSeverity() != null) {
errorInfo = "<severity>" + rpcError.getSeverity().toString().toLowerCase() + "</severity>";
}