/** * Handler some action whether some exception happened. * * @param throwable exception what happened * @param console console for displaying error */ void handleError(@NotNull Throwable throwable, GitOutputConsole console) { String errorMessage = throwable.getMessage(); if (errorMessage == null) { console.printError(constant.branchDeleteFailed()); notificationManager.notify( constant.branchDeleteFailed(), FAIL, true, project.getRootProject()); return; } try { errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage(); if (errorMessage.equals("Unable get private ssh key")) { console.printError(constant.messagesUnableGetSshKey()); notificationManager.notify( constant.messagesUnableGetSshKeyTitle(), constant.messagesUnableGetSshKey(), FAIL, true, project.getRootProject()); return; } console.printError(errorMessage); notificationManager.notify(errorMessage, FAIL, true, project.getRootProject()); } catch (Exception e) { console.printError(errorMessage); notificationManager.notify(errorMessage, FAIL, true, project.getRootProject()); } }
private void printGitMessage(String messageText, GitOutputConsole console) { if (messageText == null || messageText.isEmpty()) { return; } JSONObject jsonObject = JSONParser.parseStrict(messageText).isObject(); if (jsonObject == null) { return; } String message = ""; if (jsonObject.containsKey("message")) { message = jsonObject.get("message").isString().stringValue(); } console.print(""); String[] lines = message.split("\n"); for (String line : lines) { console.printError(line); } }