private void handleError(PromiseError error) {
   view.showLoader(false);
   final ServiceError serviceError =
       dtoFactory.createDtoFromJson(error.getMessage(), ServiceError.class);
   notificationManager.notify(serviceError.getMessage(), FAIL, true);
   view.showError(serviceError.getMessage());
 }
Esempio n. 2
0
  /**
   * 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());
    }
  }
  protected void init() {
    setProvider(getNativeProvider());
    setTemplating(
        dtoFactory.createDtoFromJson(
            javaScriptResources.completionTemplatingJson().getText(), Templating.class));

    // build trie
    buildTrie();

    // set context factory using JSNI
    setContextFactory(new JSNIContextFactory());
  }
Esempio n. 4
0
 public <T> T getAs(Class<T> type) {
   if (type.equals(String.class)) {
     return (T) result.asString();
   } else if (type.equals(Double.class)) {
     return (T) (Double) result.asNumber();
   } else if (type.equals(Boolean.class)) {
     return (T) (Boolean) result.asBoolean();
   } else if (type.equals(Void.class)) {
     return (T) null;
   } else {
     return dtoFactory.createDtoFromJson(result.toJson(), type);
   }
 }
Esempio n. 5
0
  public <T> List<T> getAsListOf(Class<T> type) {
    List<T> list = new ArrayList<>(resultList.size());

    for (int i = 0; i < resultList.size(); i++) {
      JsonValue jsonValue = resultList.get(i);
      T item;
      if (type.equals(String.class)) {
        item = (T) jsonValue.asString();
      } else if (type.equals(Double.class)) {
        item = (T) (Double) jsonValue.asNumber();
      } else if (type.equals(Boolean.class)) {
        item = (T) (Boolean) jsonValue.asBoolean();
      } else {
        item = dtoFactory.createDtoFromJson(jsonValue.toJson(), type);
      }
      list.add(i, item);
    }

    return list;
  }