use of org.eclipse.che.ide.commons.exception.UnmarshallerException in project che by eclipse.
the class RequestCallback method onReply.
/**
* Perform actions when response message was received.
*
* @param message
* message
*/
public void onReply(Message message) {
if (loader != null) {
loader.hide();
}
final String uuid = message.getStringField(MessageBuilder.UUID_FIELD);
if (message.getResponseCode() == HTTPStatus.UNAUTHORIZED) {
UnauthorizedException exception = new UnauthorizedException(message);
if (statusHandler != null) {
statusHandler.requestError(uuid, exception);
}
onFailure(exception);
return;
}
if (isSuccessful(message)) {
try {
if (unmarshaller != null) {
unmarshaller.unmarshal(message);
payload = unmarshaller.getPayload();
}
if (statusHandler != null) {
statusHandler.requestFinished(uuid);
}
onSuccess(payload);
} catch (UnmarshallerException e) {
if (statusHandler != null) {
statusHandler.requestError(uuid, e);
}
onFailure(e);
}
} else {
ServerException exception = new ServerException(message);
if (statusHandler != null) {
statusHandler.requestError(uuid, exception);
}
onFailure(exception);
}
}
use of org.eclipse.che.ide.commons.exception.UnmarshallerException in project che by eclipse.
the class SubscriptionHandler method onMessage.
/**
* Perform actions when {@link Message} was received.
*
* @param message
* received {@link Message}
*/
public void onMessage(Message message) {
if (isSuccessful(message)) {
try {
if (unmarshaller != null) {
unmarshaller.unmarshal(message);
payload = unmarshaller.getPayload();
}
onMessageReceived(payload);
} catch (UnmarshallerException e) {
onErrorReceived(e);
}
} else {
onErrorReceived(new ServerException(message));
}
}
use of org.eclipse.che.ide.commons.exception.UnmarshallerException in project che by eclipse.
the class DebuggerEventUnmarshaller method unmarshal.
@Override
public void unmarshal(Message response) throws UnmarshallerException {
JSONObject jsonObject = JSONParser.parseStrict(response.getBody()).isObject();
if (jsonObject == null) {
return;
}
if (jsonObject.containsKey("type")) {
String type = jsonObject.get("type").isString().stringValue();
TYPE eventType = TYPE.valueOf(type);
switch(eventType) {
case SUSPEND:
event = dtoFactory.createDtoFromJson(jsonObject.toString(), SuspendEventDto.class);
break;
case DISCONNECT:
event = dtoFactory.createDtoFromJson(jsonObject.toString(), DisconnectEventDto.class);
break;
case BREAKPOINT_ACTIVATED:
event = dtoFactory.createDtoFromJson(jsonObject.toString(), BreakpointActivatedEventDto.class);
break;
default:
throw new UnmarshallerException("Can't parse response.", new IllegalArgumentException("Unknown debug event type: " + eventType));
}
}
}
Aggregations