当前位置: 首页>>代码示例>>Java>>正文


Java StatusCodeException.getStatusCode方法代码示例

本文整理汇总了Java中com.google.gwt.user.client.rpc.StatusCodeException.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java StatusCodeException.getStatusCode方法的具体用法?Java StatusCodeException.getStatusCode怎么用?Java StatusCodeException.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.client.rpc.StatusCodeException的用法示例。


在下文中一共展示了StatusCodeException.getStatusCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUncaughtException

import com.google.gwt.user.client.rpc.StatusCodeException; //导入方法依赖的package包/类
@Override
public void onUncaughtException(Throwable e) {
    GWT.log("Unexpected exception", e);
    
    if(e instanceof UmbrellaException) {
        UmbrellaException umbrellaException = (UmbrellaException)e;
        if(umbrellaException.getCause() != null) {
            e = umbrellaException.getCause();
        }
        if(umbrellaException.getCauses() != null) {
            for(Throwable cause : umbrellaException.getCauses()) {
                if(cause instanceof StatusCodeException) {
                    e = cause;
                    break;
                }
            }
        }
    }
    
    if(e instanceof StatusCodeException) {
        StatusCodeException statusCodeException = (StatusCodeException)e;
        if(statusCodeException.getStatusCode() == 401 
                || statusCodeException.getStatusCode() == 403) {
            errorLabel.setText("Unauthorized");
        } else {
            errorLabel.setText("HTTP status error: " + statusCodeException.getStatusCode());
        }
    } else {
        errorLabel.setText(e.getMessage());
    }
    dialogBox.center();
}
 
开发者ID:Novartis,项目名称:ontobrowser,代码行数:33,代码来源:ErrorView.java

示例2: getServerError

import com.google.gwt.user.client.rpc.StatusCodeException; //导入方法依赖的package包/类
private String getServerError(final Throwable caught) {
    String eMsg = caught != null ? caught.getMessage() : "unknown";

    String msgExtra = "<span class=\"faded-text\">" +
            "<br><br>If you still continue to receive this message, contact IRSA for <a href='http://irsa.ipac.caltech.edu/applications/Helpdesk' target='_blank'>help</a>.  " +
            "<span>";
    String msg = "<b> Unable to load table.</b><br>";

    if (caught instanceof StatusCodeException) {
        StatusCodeException scx = (StatusCodeException) caught;
        if (scx.getStatusCode() == 503) {
            msg = "The site is down for scheduled maintenance.";
            msgExtra = "";
        } else if (scx.getStatusCode() == 0) {
            msg = "If you are not connected to the internet, check your internet connection and try again";
        } else {
            msg = "The server encountered an unexpected condition which prevented it from fulfilling the request.<br>" +
                    "Refreshing the page may resolve the problem.";
        }
    } else if (caught instanceof RPCException) {
        RPCException ex = (RPCException) caught;
        if (ex.getEndUserMsg() != null) {
            eMsg = ex.getEndUserMsg();
        }
    }
    return msg + eMsg + msgExtra;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:28,代码来源:TablePanel.java

示例3: isNotSignedIn

import com.google.gwt.user.client.rpc.StatusCodeException; //导入方法依赖的package包/类
/** True if err is describing a user that is currently anonymous. */
public static boolean isNotSignedIn(Throwable err) {
  if (err instanceof StatusCodeException) {
    StatusCodeException sce = (StatusCodeException) err;
    if (sce.getStatusCode() == Response.SC_UNAUTHORIZED) {
      return true;
    }
    return sce.getStatusCode() == Response.SC_FORBIDDEN
        && (sce.getEncodedResponse().equals("Authentication required")
            || sce.getEncodedResponse().startsWith("Must be signed-in")
            || sce.getEncodedResponse().startsWith("Invalid authentication"));
  }
  return false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RestApi.java

示例4: handleException

import com.google.gwt.user.client.rpc.StatusCodeException; //导入方法依赖的package包/类
/**
 * Exception handler.
 */
public static void handleException(Throwable caught,
                                   HasErrorMessage hasErrorMessage,
                                   ErrorMessageCustomizer errorMessageCustomizer) {
  boolean handled = false;
  if (caught instanceof StatusCodeException) {
    StatusCodeException sce = (StatusCodeException) caught;
    if (sce.getStatusCode() == Response.SC_UNAUTHORIZED) {
      onUnauthorized();
      handled = true;
    } else if (sce.getStatusCode() == 0) {
      handleNetworkConnectionError();
      handled = true;
    }
  } else if (caught instanceof IncompatibleRemoteServiceException) {
    MessageDialog.showMessageDialog(AlertPanel.Type.ERROR, constants.incompatibleRemoteService(),
        messages.incompatibleRemoteService());
    handled = true;
  }
  if (!handled) {
    String message = parseErrorMessage(caught, errorMessageCustomizer);
    String[] lines = message.split("\r\n|\r|\n");
    if (lines.length > 1 || (lines.length == 1 && lines[0].length() >= MAX_ERROR_LINE_LENGTH)) {
      MessageDialog.showMessageDialog(AlertPanel.Type.ERROR, constants.errorTitle(), message);
    } else {
      hasErrorMessage.setErrorMessage(message);
    }
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:32,代码来源:Utils.java

示例5: showSevereError

import com.google.gwt.user.client.rpc.StatusCodeException; //导入方法依赖的package包/类
public static void showSevereError(final Throwable caught) {

        String eMsg= caught == null || caught.getMessage() == null ? "unknown" : caught.getMessage();
        GWT.log(eMsg, caught);

        String msgExtra= "<span class=\"faded-text\">" +
                "<br><br>If you still continue to receive this message, contact IRSA for <a href='http://irsa.ipac.caltech.edu/applications/Helpdesk' target='_blank'>help</a>.  " +
                "<span>";
        String title = "Error";
        String msg = "An unexpected error has occurred." +
                "<br>Caused by: " + eMsg;
        String details = null;

        if (caught instanceof IncompatibleRemoteServiceException) {
            title = "Application is out of date";
            msg = "This application is out of date.  In most cases, refreshing the page will resolve the problem.";
        } else if ( caught instanceof StatusCodeException) {
            StatusCodeException scx = (StatusCodeException) caught;
            title = "Server is not available";
            details = eMsg;
            if (scx.getStatusCode() == 503) {
                msg = "The site is down for scheduled maintenance.";
                msgExtra = "";
            } else if (scx.getStatusCode() == 0) {
                title = "Server/Network is not available";
                msg = "If you are not connected to the internet, check your internet connection and try again";
            } else {
                msg = "The server encountered an unexpected condition which prevented it from fulfilling the request.<br>" +
                      "Refreshing the page may resolve the problem.";
            }
        } else if (caught instanceof RPCException) {
            RPCException ex = (RPCException)caught;
            details = ex.toHtmlString();
            if (ex.getEndUserMsg()!=null) {
                msg= ex.getEndUserMsg();
            }
        }

        showMsgWithDetails(title, msg + msgExtra, PopupType.STANDARD, details, ERROR_MSG_STYLE);

    }
 
开发者ID:lsst,项目名称:firefly,代码行数:42,代码来源:PopupUtil.java

示例6: ErrorDialog

import com.google.gwt.user.client.rpc.StatusCodeException; //导入方法依赖的package包/类
/** Create a dialog box to nicely format an exception. */
public ErrorDialog(Throwable what) {
  this();

  String hdr;
  String msg;

  if (what instanceof StatusCodeException) {
    StatusCodeException sc = (StatusCodeException) what;
    if (RestApi.isExpected(sc.getStatusCode())) {
      hdr = null;
      msg = sc.getEncodedResponse();
    } else if (sc.getStatusCode() == Response.SC_INTERNAL_SERVER_ERROR) {
      hdr = null;
      msg = what.getMessage();
    } else {
      hdr = RpcConstants.C.errorServerUnavailable();
      msg = what.getMessage();
    }

  } else if (what instanceof RemoteJsonException) {
    // TODO Remove RemoteJsonException from Gerrit sources.
    hdr = RpcConstants.C.errorRemoteJsonException();
    msg = what.getMessage();

  } else {
    // TODO Fix callers of ErrorDialog to stop passing random types.
    hdr = what.getClass().getName();
    if (hdr.startsWith("java.lang.")) {
      hdr = hdr.substring("java.lang.".length());
    } else if (hdr.startsWith("com.google.gerrit.")) {
      hdr = hdr.substring(hdr.lastIndexOf('.') + 1);
    }
    if (hdr.endsWith("Exception")) {
      hdr = hdr.substring(0, hdr.length() - "Exception".length());
    } else if (hdr.endsWith("Error")) {
      hdr = hdr.substring(0, hdr.length() - "Error".length());
    }
    msg = what.getMessage();
  }

  if (hdr != null) {
    final Label r = new Label(hdr);
    r.setStyleName(Gerrit.RESOURCES.css().errorDialogErrorType());
    body.add(r);
  }

  if (msg != null) {
    final Label m = new Label(msg);
    m.getElement().getStyle().setProperty("whiteSpace", "pre");
    body.add(m);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:54,代码来源:ErrorDialog.java


注:本文中的com.google.gwt.user.client.rpc.StatusCodeException.getStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。