public ApiException(ServiceError serviceError) { super(serviceError.getMessage()); this.serviceError = serviceError; }
@Override public Response toResponse(RuntimeException exception) { final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); final String utcTime = dateFormat.format(new Date()); final String errorMessage = format("Internal Server Error occurred, error time: %s", utcTime); LOG.error(errorMessage, exception); ServiceError serviceError = DtoFactory.newDto(ServiceError.class).withMessage(errorMessage); return Response.serverError() .entity(DtoFactory.getInstance().toJson(serviceError)) .type(MediaType.APPLICATION_JSON) .build(); } }
public ServiceErrorImpl(org.eclipse.che.api.core.rest.shared.dto.ServiceError origin) { this.message = origin.getMessage(); }
private ServiceError createError(String message) { return DtoFactory.getInstance().createDto(ServiceError.class).withMessage(message); } }
final ServiceError serviceError = DtoFactory.getInstance().createDtoFromJson(str, ServiceError.class); if (serviceError.getMessage() != null) { if (responseCode == Response.Status.FORBIDDEN.getStatusCode()) { throw new ForbiddenException(serviceError);
@Override public Response toResponse(InstallerException exception) { ServiceError serviceError = DtoFactory.newDto(ServiceError.class).withMessage(exception.getMessage()); String errorAsJson = DtoFactory.getInstance().toJson(serviceError); if (exception instanceof InstallerNotFoundException) { return Response.status(Response.Status.NOT_FOUND) .entity(errorAsJson) .type(MediaType.APPLICATION_JSON) .build(); } else if (exception instanceof InstallerAlreadyExistsException) { return Response.status(Response.Status.CONFLICT) .entity(errorAsJson) .type(MediaType.APPLICATION_JSON) .build(); } else if (exception instanceof IllegalInstallerKeyException) { return Response.status(Response.Status.BAD_REQUEST) .entity(errorAsJson) .type(MediaType.APPLICATION_JSON) .build(); } else { return Response.serverError().entity(errorAsJson).type(MediaType.APPLICATION_JSON).build(); } } }
final ServiceError serviceError = DtoFactory.getInstance().createDtoFromJson(str, ServiceError.class); if (serviceError.getMessage() != null) { if (responseCode == Response.Status.FORBIDDEN.getStatusCode()) { throw new ForbiddenException(serviceError);
ConflictExceptionError conflictExceptionError = newDto(ConflictExceptionError.class) .withMessage(exception.getServiceError().getMessage()) .withConflictingPaths(((GitConflictException) exception).getConflictPaths()); return Response.status(Response.Status.CONFLICT)
errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage(); if (errorMessage.equals("Unable get private ssh key")) { console.printError(locale.messagesUnableGetSshKey());
errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage(); if (errorMessage.equals("Unable get private ssh key")) { console.printError(locale.messagesUnableGetSshKey());