コード例 #1
0
ファイル: ExceptionDialogUtil.java プロジェクト: huokedu/josm
  /**
   * Explains an {@link OsmTransferException} to the user.
   *
   * @param e the {@link OsmTransferException}
   */
  public static void explainOsmTransferException(OsmTransferException e) {
    if (getNestedException(e, SecurityException.class) != null) {
      explainSecurityException(e);
      return;
    }
    if (getNestedException(e, SocketException.class) != null) {
      explainNestedSocketException(e);
      return;
    }
    if (getNestedException(e, UnknownHostException.class) != null) {
      explainNestedUnkonwnHostException(e);
      return;
    }
    if (getNestedException(e, IOException.class) != null) {
      explainNestedIOException(e);
      return;
    }
    if (getNestedException(e, IllegalDataException.class) != null) {
      explainNestedIllegalDataException(e);
      return;
    }
    if (e instanceof OsmApiInitializationException) {
      explainOsmApiInitializationException((OsmApiInitializationException) e);
      return;
    }

    if (e instanceof ChangesetClosedException) {
      explainChangesetClosedException((ChangesetClosedException) e);
      return;
    }

    if (e instanceof MissingOAuthAccessTokenException) {
      explainMissingOAuthAccessTokenException((MissingOAuthAccessTokenException) e);
      return;
    }

    if (e instanceof OsmApiException) {
      OsmApiException oae = (OsmApiException) e;
      switch (oae.getResponseCode()) {
        case HttpURLConnection.HTTP_PRECON_FAILED:
          explainPreconditionFailed(oae);
          return;
        case HttpURLConnection.HTTP_GONE:
          explainGoneForUnknownPrimitive(oae);
          return;
        case HttpURLConnection.HTTP_INTERNAL_ERROR:
          explainInternalServerError(oae);
          return;
        case HttpURLConnection.HTTP_BAD_REQUEST:
          explainBadRequest(oae);
          return;
        case HttpURLConnection.HTTP_NOT_FOUND:
          explainNotFound(oae);
          return;
        case HttpURLConnection.HTTP_CONFLICT:
          explainConflict(oae);
          return;
        case HttpURLConnection.HTTP_UNAUTHORIZED:
          explainAuthenticationFailed(oae);
          return;
        case HttpURLConnection.HTTP_FORBIDDEN:
          explainAuthorizationFailed(oae);
          return;
        case HttpURLConnection.HTTP_CLIENT_TIMEOUT:
          explainClientTimeout(oae);
          return;
        case 509:
          explainBandwidthLimitExceeded(oae);
          return;
        default:
          explainGenericHttpException(oae);
          return;
      }
    }
    explainGeneric(e);
  }