public static P4CommandRunner.ServerResultException createException( @NotNull P4CommandRunner.ErrorCategory category, @Nullable String message, @Nullable Throwable t) { // Avoid needing to initialize the VcsBundle by always including an exception with a message. if (t == null) { t = new RuntimeException("blah"); } if (message == null) { if (t.getMessage() == null) { throw new IllegalArgumentException("Better add in a message, or you'll be sorry."); } message = t.getMessage(); } return new P4CommandRunner.ServerResultException(createResultError(category, message), t); }
.whenServerError((err) -> { UserMessage.showNotification(myProject, UserMessage.ERROR, err.getLocalizedMessage(), P4Bundle.message("error.remove-changelist.title", p4change.getChangelistId()), NotificationType.ERROR);
.whenFailed(err -> { UserMessage.showNotification(myProject, UserMessage.ERROR, P4Bundle.message("error.changelist-file-move", err.getLocalizedMessage()), P4Bundle.message("error.changelist-file-move.title"), NotificationType.ERROR);
LOG.info("Server connection attempt failed", err); parentPart.addAdditionalProblem( new ConfigProblem(null, err.getLocalizedMessage(), false)); if (LOG.isDebugEnabled()) { LOG.debug("Sending refresh complete notice with configuration " +
assertEquals(e.getResultError().getCategory(), P4CommandRunner.ErrorCategory.ACCESS_DENIED); assertEquals(e.getLocalizedMessage(), e.getLocalizedMessage()); assertThat(e.getResultError().getMessage().orElse(null), containsString(e.getLocalizedMessage())); });
P4CommandRunner.ResultError re = t.getResultError(); assertEquals(P4CommandRunner.ErrorCategory.SERVER_ERROR, re.getCategory()); assertTrue(re.getMessage().isPresent());
.whenServerError((ex) -> { assertNotNull(ex); assertThat(ex.getCause(), instanceOf(RequestException.class));
P4CommandRunner.ResultError re = t.getResultError(); assertEquals(P4CommandRunner.ErrorCategory.SERVER_ERROR, re.getCategory()); assertTrue(re.getMessage().isPresent());
static <S> Answer<S> forPromise(@NotNull Promise<S> p) { AsyncAnswer<S> ret = new AsyncAnswer<>(); p .then((s) -> { ret.resolve(s); return s; }) .rejected((t) -> { if (t instanceof P4CommandRunner.ServerResultException) { ret.reject((P4CommandRunner.ServerResultException) t); } else { ret.reject(new P4CommandRunner.ServerResultException(new P4CommandRunner.ResultError() { @NotNull @Override public P4CommandRunner.ErrorCategory getCategory() { return P4CommandRunner.ErrorCategory.INTERNAL; } @Nls @NotNull @Override public Optional<String> getMessage() { return Optional.ofNullable(t.getLocalizedMessage()); } }, t)); } }); return ret; }
@Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); progressIndicator.startNonCancelableSection(); try { LOG.info("Fetching files into " + rootPath); FetchFilesResult r = P4ServerComponent .perform(project, clientConfig, new FetchFilesAction(Collections.singletonList(rootPath), null, false)) .blockingGet(UserProjectPreferences.getLockWaitTimeoutMillis(project), TimeUnit.MILLISECONDS); progressIndicator.finishNonCancelableSection(); synchronized (sync) { res = r; } } catch (InterruptedException e) { InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>( new VcsInterruptedException(e))); progressIndicator.finishNonCancelableSection(); onCancel(); } catch (P4CommandRunner.ServerResultException e) { progressIndicator.finishNonCancelableSection(); VcsNotifier.getInstance(project).notifyError(P4Bundle.getString("checkout.config.error.title"), e.getMessage()); synchronized (sync) { res = null; } } progressIndicator.stop(); }
@Test void map_reject() { AsyncAnswer<Object> answer1 = new AsyncAnswer<>(); Answer<Object> answer2 = answer1.map((c) -> "b"); answer2.whenCompleted((c) -> fail("Should never be called")); P4CommandRunner.ServerResultException sre = new P4CommandRunner.ServerResultException( new P4CommandRunner.ResultError() { @NotNull @Override public P4CommandRunner.ErrorCategory getCategory() { return P4CommandRunner.ErrorCategory.CONNECTION; } @Nls @NotNull @Override public Optional<String> getMessage() { return Optional.empty(); } }); answer2.whenFailed((actual) -> assertSame(sre, actual)); answer1.reject(sre); }
public static P4CommandRunner.ServerResultException createSwarmError(final Exception e) { return new P4CommandRunner.ServerResultException(new P4CommandRunner.ResultError() { @NotNull @Override public P4CommandRunner.ErrorCategory getCategory() { return P4CommandRunner.ErrorCategory.SWARM; } @Nls @NotNull @Override public Optional<String> getMessage() { return Optional.of(e.getLocalizedMessage() == null ? "General swarm problem" : e.getLocalizedMessage()); } }, e); } }
public static P4CommandRunner.ServerResultException createFor(InterruptedException e) { return new P4CommandRunner.ServerResultException(new TimeoutResultError(e)); }
public static P4CommandRunner.ServerResultException createOfflineError() { return new P4CommandRunner.ServerResultException(OFFLINE_RESULT_ERROR); }
public static P4CommandRunner.ServerResultException createFor(CancellationException e) { return new P4CommandRunner.ServerResultException(new TimeoutResultError(e)); }
private static P4CommandRunner.ActionAnswer<ShelveFilesResult> shelveFiles(Project project, ClientConfig clientConfig, P4ChangelistId changelistId, List<FilePath> files) { return P4ServerComponent.perform(project, clientConfig, new ShelveFilesAction(changelistId, files)) .whenServerError(e -> { // Error messages are handled by the user error section SwarmErrorMessage.send(project).couldNotShelveFiles(new SwarmErrorMessage.SwarmEvent(changelistId), P4Bundle.message("swarm-client.shelve.failed", e.getLocalizedMessage())); }) .whenOffline(() -> { SwarmErrorMessage.send(project).couldNotShelveFiles(new SwarmErrorMessage.SwarmEvent(changelistId), P4Bundle.message("swarm-client.shelve.offline")); }); }
private ProxyColumnInfo(ColumnInfo<T, Aspect> proxy, Runnable listener) { super(proxy.getName()); this.proxy = proxy; this.listener = listener; }
@NotNull protected final P4CommandRunner.ServerResultException createServerResultException(@Nullable Error e, @Nls(capitalization = Nls.Capitalization.Sentence) @NotNull String message, @NotNull P4CommandRunner.ErrorCategory category) { return new P4CommandRunner.ServerResultException( new ResultErrorImpl(message, category), e); }
@NotNull protected final P4CommandRunner.ServerResultException createServerResultException(@Nullable Exception e, @Nls(capitalization = Nls.Capitalization.Sentence) @NotNull String message, @NotNull P4CommandRunner.ErrorCategory category) { return new P4CommandRunner.ServerResultException( new ResultErrorImpl(message, category), e); }