@Override public Promise<Project> apply(PromiseError exception) throws FunctionException { subscriber.onFailure(exception.getCause().getMessage()); switch (getErrorCode(exception.getCause())) { case UNABLE_GET_PRIVATE_SSH_KEY: throw new IllegalStateException( localizationConstant.importProjectMessageUnableGetSshKey()); case UNAUTHORIZED_SVN_OPERATION: return recallImportWithCredentials(sourceStorage, path); case UNAUTHORIZED_GIT_OPERATION: final Map<String, String> attributes = ExceptionUtils.getAttributes(exception.getCause()); final String providerName = attributes.get(PROVIDER_NAME); final String authenticateUrl = attributes.get(AUTHENTICATE_URL); if (!Strings.isNullOrEmpty(providerName) && !Strings.isNullOrEmpty(authenticateUrl)) { return authUserAndRecallImport( providerName, authenticateUrl, path, sourceStorage, subscriber); } else { throw new IllegalStateException( localizationConstant.oauthFailedToGetAuthenticatorText()); } default: throw new IllegalStateException(exception.getCause()); } } });
private void fetchRevisions() { service .log( project.getLocation(), selectedPath.isEmpty() ? null : new Path[] {selectedPath}, skip, DEFAULT_PAGE_SIZE, false) .then( log -> { List<Revision> commits = log.getCommits(); if (!commits.isEmpty()) { skip += commits.size(); revisions.addAll(commits); view.setRevisions(revisions); view.showDialog(); } }) .catchError( error -> { if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) { dialogFactory .createMessageDialog( locale.historyTitle(), locale.initCommitWasNotPerformed(), null) .show(); } else { notificationManager.notify(locale.logFailed(), FAIL, EMERGE_MODE); } }); }
if (getErrorCode(exception) == ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY) { dialogFactory .createMessageDialog(commandName, constant.messagesUnableGetSshKey(), null)
@Override public Promise<Y> apply(PromiseError error) throws FunctionException { if (getErrorCode(error.getCause()) == ErrorCodes.UNAUTHORIZED_GIT_OPERATION) { Map<String, String> attributes = getAttributes(error.getCause()); String providerName = attributes.get(PROVIDER_NAME); return oAuthServiceClient .getToken(providerName) .thenPromise( token -> Promises.resolve(new Credentials(token.getToken(), token.getToken()))) .thenPromise(operation::perform) .catchError( (Operation<PromiseError>) err -> notificationManager.notify( locale.messagesNotAuthorizedContent(), FAIL, FLOAT_MODE)); } return Promises.reject(error); } });
.catchError( error -> { if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) { service
.catchErrorPromise( caught -> { int errorCode = ExceptionUtils.getErrorCode(caught.getCause()); switch (errorCode) { case UNAUTHORIZED_GIT_OPERATION: subscriber.onFailure(caught.getMessage()); Map<String, String> attributes = getAttributes(caught.getCause()); String providerName = attributes.get(PROVIDER_NAME); String authenticateUrl = attributes.get(AUTHENTICATE_URL);
.catchError( error -> { if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) { dialogFactory .createMessageDialog(
.catchError( error -> { if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) { dialogFactory .createMessageDialog(
/** Get list of revisions. */ private void getRevisions() { service .log(project.getLocation(), new Path[] {selectedFilePath}, -1, -1, false) .then( log -> { view.setRevisions(log.getCommits()); view.showDialog(); }) .catchError( error -> { if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) { dialogFactory .createMessageDialog( locale.compareWithRevisionTitle(), locale.initCommitWasNotPerformed(), null) .show(); } else { notificationManager.notify(locale.logFailed(), FAIL, NOT_EMERGE_MODE); } }); }
int errorCode = getErrorCode(exception); if (errorCode == ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED) { dialogFactory