use of org.ow2.proactive_grid_cloud_portal.cli.json.ErrorView in project scheduling by ow2-proactive.
the class AbstractCommand method buildCLIException.
protected CLIException buildCLIException(int reason, HttpResponseWrapper response, ApplicationContext currentContext) {
String responseContent = StringUtility.responseAsString(response);
ErrorView errorView = errorView(responseContent, currentContext);
if (errorView != null) {
throw new CLIException(reason, errorView.getErrorMessage(), errorView.getStackTrace());
} else {
HttpErrorView httpErrorView = errorView(responseContent);
throw new CLIException(reason, httpErrorView.errorMessage, httpErrorView.stackTrace);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.ErrorView in project scheduling by ow2-proactive.
the class AbstractCommand method handleError.
@SuppressWarnings("unchecked")
protected void handleError(String errorMessage, HttpResponseWrapper response, ApplicationContext currentContext) {
String responseContent = StringUtility.responseAsString(response);
Stack resultStack = resultStack(currentContext);
ErrorView errorView = errorView(responseContent, currentContext);
if (errorView != null) {
resultStack.push(errorView);
} else {
resultStack.push(responseContent);
}
if (errorView != null) {
writeError(errorMessage, errorView, currentContext);
} else {
writeError(errorMessage, responseContent, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.ErrorView in project scheduling by ow2-proactive.
the class AbstractCommand method errorView.
protected HttpErrorView errorView(String responseContent) {
try {
HttpErrorView errorView = new HttpErrorView();
BufferedReader reader = new BufferedReader(new StringReader(responseContent));
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("errorMessage:")) {
errorView.errorMessage = line.substring(line.indexOf(':')).trim();
break;
}
}
while ((line = reader.readLine()) != null) {
if (line.startsWith("httpErrorCode:")) {
errorView.errorCode = line.substring(line.indexOf(':')).trim();
break;
}
}
while ((line = reader.readLine()) != null) {
if (line.startsWith("stackTrace:")) {
StringBuilder buffer = new StringBuilder();
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
errorView.stackTrace = buffer.toString();
break;
}
}
return errorView;
} catch (IOException ioe) {
throw new CLIException(REASON_IO_ERROR, ioe);
}
}
Aggregations