/**
   * 运行时,添加JVM参数“-Dsun.net.http.retryPost=false”,可阻止自动重连。
   *
   * @see 'http://www.coderanch.com/t/490463/sockets/java/Timeout-retry-URLHTTPRequest'
   */
  @Test
  public void testConnectionResetByHttpURLConnection() throws IOException {
    testConnectionResetCount = 0;

    String resp = null;
    try {
      HttpURLConnection conn =
          (HttpURLConnection) new URL("http://localhost:65532/soso").openConnection();
      conn.setDoOutput(true);
      conn.setRequestMethod("POST");
      conn.getOutputStream().write("username".getBytes());
      resp = conn.getResponseCode() + "";
    } catch (IOException e) {
      Throwable ee = ExceptionUtils.getRootCause(e);
      if (ee == null) {
        ee = e;
      }
      Logger.error(this, "", ee);
      Assert.assertNotSame(NoHttpResponseException.class, ee.getClass());
      Assert.assertSame(SocketException.class, ee.getClass());
      Assert.assertTrue(
          "Connection reset".equals(ee.getMessage())
              || "Socket closed".equals(ee.getMessage())
              || "Unexpected end of file from server".equals(ee.getMessage()));
    } finally {
      Logger.info(
          this,
          "resp[HttpURLConnection]-["
              + testConnectionResetCount
              + "]=========["
              + resp
              + "]=========");
    }
    Assert.assertEquals(2, testConnectionResetCount);
  }
  private static void assertExceptionOccurred(
      boolean shouldOccur, AbstractExceptionCase exceptionCase, String expectedErrorMsg)
      throws Throwable {
    boolean wasThrown = false;
    try {
      exceptionCase.tryClosure();
    } catch (Throwable e) {
      if (shouldOccur) {
        wasThrown = true;
        final String errorMessage = exceptionCase.getAssertionErrorMessage();
        assertEquals(errorMessage, exceptionCase.getExpectedExceptionClass(), e.getClass());
        if (expectedErrorMsg != null) {
          assertEquals("Compare error messages", expectedErrorMsg, e.getMessage());
        }
      } else if (exceptionCase.getExpectedExceptionClass().equals(e.getClass())) {
        wasThrown = true;

        System.out.println("");
        e.printStackTrace(System.out);

        fail("Exception isn't expected here. Exception message: " + e.getMessage());
      } else {
        throw e;
      }
    } finally {
      if (shouldOccur && !wasThrown) {
        fail(exceptionCase.getAssertionErrorMessage());
      }
    }
  }
  public DynamicObject translate(Throwable throwable) {
    if (getContext().getOptions().EXCEPTIONS_PRINT_JAVA
        || (boolean) getContext().getOptions().EXCEPTIONS_PRINT_UNCAUGHT_JAVA) {
      throwable.printStackTrace();
    }

    if (throwable.getStackTrace().length > 0) {
      return getContext()
          .getCoreLibrary()
          .internalError(
              String.format(
                  "%s %s %s",
                  throwable.getClass().getSimpleName(),
                  throwable.getMessage(),
                  throwable.getStackTrace()[0].toString()),
              this);
    } else {
      return getContext()
          .getCoreLibrary()
          .internalError(
              String.format(
                  "%s %s ???", throwable.getClass().getSimpleName(), throwable.getMessage()),
              this);
    }
  }
Beispiel #4
0
  public static String getExceptionStack(Throwable t) {
    StringBuffer buf = new StringBuffer();
    // get exception stack
    List exceptions = getExceptionsAsList(t);

    int i = 1;
    for (Iterator iterator = exceptions.iterator(); iterator.hasNext(); i++) {
      if (i > exceptionThreshold && exceptionThreshold > 0) {
        buf.append("(").append(exceptions.size() - i + 1).append(" more...)");
        break;
      }
      Throwable throwable = (Throwable) iterator.next();
      ExceptionReader er = getExceptionReader(throwable);
      buf.append(i).append(". ").append(er.getMessage(throwable)).append(" (");
      buf.append(throwable.getClass().getName()).append(")\n");
      if (verbose && throwable.getStackTrace().length > 0) {
        StackTraceElement e = throwable.getStackTrace()[0];
        buf.append("  ")
            .append(e.getClassName())
            .append(":")
            .append(e.getLineNumber())
            .append(" (")
            .append(getJavaDocUrl(throwable.getClass()))
            .append(")\n");
      }
    }
    return buf.toString();
  }
 private static String collapseText(
     Throwable t, boolean includeAllCausalMessages, Set<Throwable> visited) {
   if (t == null) return null;
   if (visited.contains(t)) {
     // IllegalStateException sometimes refers to itself; guard against stack overflows
     if (Strings.isNonBlank(t.getMessage())) return t.getMessage();
     else return "(" + t.getClass().getName() + ", recursive cause)";
   }
   Throwable t2 = collapse(t, true, includeAllCausalMessages, visited);
   visited = MutableSet.copyOf(visited);
   visited.add(t);
   visited.add(t2);
   if (t2 instanceof PropagatedRuntimeException) {
     if (((PropagatedRuntimeException) t2).isCauseEmbeddedInMessage())
       // normally
       return t2.getMessage();
     else if (t2.getCause() != null)
       return collapseText(t2.getCause(), includeAllCausalMessages, ImmutableSet.copyOf(visited));
     return "" + t2.getClass();
   }
   String result = t2.toString();
   if (!includeAllCausalMessages) {
     return result;
   }
   Throwable cause = t2.getCause();
   if (cause != null) {
     String causeResult = collapseText(new PropagatedRuntimeException(cause));
     if (result.indexOf(causeResult) >= 0) return result;
     return result + "; caused by " + causeResult;
   }
   return result;
 }
  @Test
  public void testConnectionResetByHttpClientUtils() throws IOException {
    testConnectionResetCount = 0;

    httpClientUtils = new HttpClientUtils();
    httpClientUtils.initHttpClient();
    Logger.info(this, "-------------- HttpClient initialized -------------");

    String resp = null;
    try {
      resp = httpClientUtils.get("http://localhost:65532/soso");
    } catch (IOException e) {
      Throwable ee = ExceptionUtils.getRootCause(e);
      if (ee == null) {
        ee = e;
      }
      Logger.error(this, "", ee);
      Assert.assertNotSame(NoHttpResponseException.class, ee.getClass());
      Assert.assertSame(SocketException.class, ee.getClass());
      Assert.assertTrue(
          "Connection reset".equals(ee.getMessage())
              || "Socket closed".equals(ee.getMessage())
              || "Unexpected end of file from server".equals(ee.getMessage()));
    } finally {
      Logger.info(
          this,
          "resp[HttpURLConnection]-["
              + testConnectionResetCount
              + "]=========["
              + resp
              + "]=========");
    }
    Assert.assertEquals(1, testConnectionResetCount);
  }
  @Override
  public void handleOpenSuccess(int recipient, int rwSize, int packetSize, Buffer buffer) {
    setRecipient(recipient);

    Session session = getSession();
    FactoryManager manager =
        ValidateUtils.checkNotNull(session.getFactoryManager(), "No factory manager");
    this.remoteWindow.init(rwSize, packetSize, manager.getProperties());
    ChannelListener listener = getChannelListenerProxy();
    try {
      doOpen();

      listener.channelOpenSuccess(this);
      this.opened.set(true);
      this.openFuture.setOpened();
    } catch (Throwable t) {
      Throwable e = GenericUtils.peelException(t);
      try {
        listener.channelOpenFailure(this, e);
      } catch (Throwable ignored) {
        log.warn(
            "handleOpenSuccess({}) failed ({}) to inform listener of open failure={}: {}",
            this,
            ignored.getClass().getSimpleName(),
            e.getClass().getSimpleName(),
            ignored.getMessage());
      }

      this.openFuture.setException(e);
      this.closeFuture.setClosed();
      this.doCloseImmediately();
    } finally {
      notifyStateChanged();
    }
  }
  private List toMessages(String target, Throwable cause) {
    if (cause.getCause() != null) {
      return toMessages(target, cause.getCause());
    }

    if (cause instanceof MultipleArtifactsNotFoundException) {
      final MultipleArtifactsNotFoundException manfe = (MultipleArtifactsNotFoundException) cause;
      return parseMissingDependenciesFromFormattedMessage(target, manfe.getMessage());
    }

    try {
      final String longMessage =
          (String)
              cause
                  .getClass()
                  .getMethod("getLongMessage", (Class[]) null)
                  .invoke(cause, (Object[]) null);
      return parseCompileFailuresFromFormattedMessage(target, longMessage);
    } catch (Exception e) {
    }

    return Collections.singletonList(
        new AntEventSummary(
            Constants.MESSAGE_LOGGED,
            null,
            target,
            null,
            cause.getClass().getName() + ": " + cause.getMessage(),
            0));
  }
  public AssertException(Class<? extends Throwable> eType, Class<? extends Throwable> eCauseType) {
    try {
      run();
    } catch (Throwable e) {
      if (e.getClass() != eType) {
        assertFail(
            "Expecting <"
                + eType.getName()
                + ">, but <"
                + e.getClass().getName()
                + "> was thrown.");
      }

      if (e.getCause().getClass() != eCauseType) {
        assertFail(
            "Expecting cause <"
                + eCauseType.getName()
                + ">, but <"
                + e.getCause().getClass().getName()
                + "> was the cause.");
      }
      return;
    }
    assertFail("Expecting <" + eType.getName() + ">");
  }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   Channel ch = e.getChannel();
   Throwable cause = e.getCause();
   if (cause instanceof TooLongFrameException) {
     sendError(ctx, HttpResponseStatus.BAD_REQUEST);
     return;
   }
   if (cause != null) {
     if (cause.getClass().equals(IOException.class)) {
       LOGGER.debug("Connection error: " + cause);
       StartStopListenerDelegate startStopListenerDelegate =
           (StartStopListenerDelegate) ctx.getAttachment();
       if (startStopListenerDelegate != null) {
         LOGGER.debug("Premature end, stopping...");
         startStopListenerDelegate.stop();
       }
     } else if (!cause.getClass().equals(ClosedChannelException.class)) {
       LOGGER.debug("Caught exception: " + cause);
     }
   }
   if (ch.isConnected()) {
     sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR);
   }
   e.getChannel().close();
 }
Beispiel #11
0
 public static boolean isCancelled(Throwable t) {
   if (t == null) {
     return false;
   }
   if (handler == null) {
     handler = (CancelHandler) DIContainerUtil.getComponentNoException(CancelHandler.class);
     if (handler == null) {
       return false;
     }
   }
   final List candidates = handler.getCancellableExceptions();
   for (Iterator itr = candidates.iterator(); itr.hasNext(); ) {
     Class tc = (Class) itr.next();
     if (t.getClass() == tc) {
       logger.log("WTDA0206", new Object[] {t});
       return true;
     }
   }
   final List nameCandidates = handler.getCancellableExceptionNames();
   for (Iterator itr = nameCandidates.iterator(); itr.hasNext(); ) {
     final String name = (String) itr.next();
     if (t.getClass().getName().endsWith(name)) {
       logger.log("WTDA0206", new Object[] {t});
       return true;
     }
   }
   return false;
 }
 /**
  * CAUTION: Decompiled by hand.
  *
  * @throws Exception
  */
 private void connect() throws Exception {
   try {
     String s;
     if (bSecure) {
       s = "t3s";
       System.setProperty("weblogic.security.SSL.ignoreHostnameVerification", "true");
       HttpsURLConnection.setDefaultHostnameVerifier(new NullHostnameVerifier());
     } else {
       s = "t3";
     }
     Hashtable hashtable = new Hashtable();
     hashtable.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
     hashtable.put("java.naming.provider.url", s + "://" + host);
     if (username.length() > 0 && password.length() > 0) {
       hashtable.put("java.naming.security.principal", username);
       hashtable.put("java.naming.security.credentials", password);
     }
     ClassLoader classloader = Thread.currentThread().getContextClassLoader();
     Class class1 = classloader.loadClass("javax.naming.InitialContext");
     Constructor constructor = class1.getConstructor(new Class[] {java.util.Hashtable.class});
     Method method = class1.getMethod("lookup", new Class[] {String.class});
     Object obj = constructor.newInstance(new Object[] {hashtable});
     Object obj1 = method.invoke(obj, new Object[] {"weblogic.management.home.localhome"});
     mbs = obj1.getClass().getMethod("getMBeanServer", null).invoke(obj1, null);
     LogManager.log("RunMonitor", "WebLogic6x: Connected");
   } catch (Throwable throwable) {
     Throwable throwable1 = throwable.getCause();
     if (throwable1 != null) {
       LogManager.log("Error", "WebLogic exception cause: " + throwable1.toString());
       String s1 = throwable1.getClass().getName();
       if ("javax.naming.NoInitialContextException".equals(s1)) {
         LogManager.log("Error", throwable.toString());
         throw new Exception("No WebLogic server found on " + host);
       }
       if ("javax.naming.AuthenticationException".equals(s1)) {
         LogManager.log("Error", throwable.toString());
         throw new Exception("Access denied for user " + username);
       }
       if ("javax.naming.CommunicationException".equals(s1)) {
         LogManager.log("Error", throwable.toString());
         throw new Exception("No WebLogic server found on " + host);
       }
     } else {
       LogManager.log("Error", "Exception '" + throwable.toString() + "' with cause == null");
     }
     throwable.printStackTrace();
     LogManager.log("Error", throwable.toString());
     String s2 = throwable.getClass().getName();
     if (s2.equals("weblogic.management.NoAccessRuntimeException")) {
       throw new Exception("Access denied for user " + username);
     }
     if (s2.equals("weblogic.common.internal.VersioningError")) {
       throw new Exception(
           "Server may be running external jar files. This is a known WebLogic issue and has a few workarounds:\n1. Place the jar file after the weblogic.jar entry in the classpath\n2. Instead of a jar file, keep the external classes in a directory structure and include the root directory instead of the jar file in classpatch\n3. If all else fails, provide the path to the weblogic jar file in the provided edit field of the \"Choose Counters\" screen");
     } else {
       throw new Exception("Unhandled exception thrown: " + s2 + " See log for details");
     }
   }
 }
Beispiel #13
0
 /** Implementation IExceptionReporter * */
 public void reportException(Throwable e) {
   if (e instanceof ApplicationLaunchException) destroyRuntime();
   displayView.setError(
       e,
       e.getClass().getName().substring(e.getClass().getName().lastIndexOf('.') + 1)
           + " : "
           + e.getMessage());
 }
Beispiel #14
0
  private Object preprocess(Throwable t) {
    String message = t.getMessage();

    if (message != null) {
      return getSimpleClassName(t.getClass()) + " - " + message;
    } else {
      return getSimpleClassName(t.getClass());
    }
  }
Beispiel #15
0
  /**
   * @param e
   * @return A ClientResponse containing error information
   */
  protected ClientResponseImpl getErrorResponse(Throwable eIn) {
    // use local var to avoid warnings about reassigning method argument
    Throwable e = eIn;
    boolean expected_failure = true;
    StackTraceElement[] stack = e.getStackTrace();
    ArrayList<StackTraceElement> matches = new ArrayList<StackTraceElement>();
    for (StackTraceElement ste : stack) {
      if (ste.getClassName().equals(m_procedure.getClass().getName())) matches.add(ste);
    }

    byte status = ClientResponse.UNEXPECTED_FAILURE;
    StringBuilder msg = new StringBuilder();

    if (e.getClass() == VoltAbortException.class) {
      status = ClientResponse.USER_ABORT;
      msg.append("USER ABORT\n");
    } else if (e.getClass() == org.voltdb.exceptions.ConstraintFailureException.class) {
      status = ClientResponse.GRACEFUL_FAILURE;
      msg.append("CONSTRAINT VIOLATION\n");
    } else if (e.getClass() == org.voltdb.exceptions.SQLException.class) {
      status = ClientResponse.GRACEFUL_FAILURE;
      msg.append("SQL ERROR\n");
    } else if (e.getClass() == org.voltdb.ExpectedProcedureException.class) {
      msg.append("HSQL-BACKEND ERROR\n");
      if (e.getCause() != null) e = e.getCause();
    } else if (e.getClass() == org.voltdb.exceptions.TransactionRestartException.class) {
      status = ClientResponse.TXN_RESTART;
      msg.append("TRANSACTION RESTART\n");
    } else {
      msg.append("UNEXPECTED FAILURE:\n");
      expected_failure = false;
    }

    // if the error is something we know can happen as part of normal
    // operation, reduce the verbosity.  Otherwise, generate
    // more output for debuggability
    if (expected_failure) {
      msg.append("  ").append(e.getMessage());
      for (StackTraceElement ste : matches) {
        msg.append("\n    at ");
        msg.append(ste.getClassName()).append(".").append(ste.getMethodName());
        msg.append("(").append(ste.getFileName()).append(":");
        msg.append(ste.getLineNumber()).append(")");
      }
    } else {
      Writer result = new StringWriter();
      PrintWriter pw = new PrintWriter(result);
      e.printStackTrace(pw);
      msg.append("  ").append(result.toString());
    }

    return getErrorResponse(
        status,
        msg.toString(),
        e instanceof SerializableException ? (SerializableException) e : null);
  }
 private Pair<Status, Integer> getHttpStatusAndErrorCode(Throwable t) {
   Pair<Response.Status, Integer> pair =
       HTTP_STATUS_AND_ERROR_CODE_BY_THROWABLE_TYPE.get(t.getClass());
   if (pair != null) {
     return pair;
   }
   // Try super class
   pair = HTTP_STATUS_AND_ERROR_CODE_BY_THROWABLE_TYPE.get(t.getClass().getSuperclass());
   return pair != null ? pair : new ImmutablePair<>(Response.Status.INTERNAL_SERVER_ERROR, 9008);
 }
 // @Override
 public void onException(Throwable error, WebDriver driver) {
   if (error.getClass().equals(NoSuchElementException.class)) {
     log.error("WebDriver error: Element not found " + lastFindBy);
   } else if (error.getClass().equals(StaleElementReferenceException.class)) {
     log.error(
         "WebDriver error: StaleElementReferenceException occurred while finding " + lastFindBy);
   } else {
     log.error("WebDriver error:", error);
   }
 }
    /**
     * Tests one method. (Disturbs members set by makeArgsAndLabel, but those shouldn't be used
     * except by this method.)
     */
    private void testOneMethod(Method method) {
      final String methodLabel = makeLabel(method);

      try {
        final INTF jdbcObject;
        try {
          jdbcObject = getJdbcObject();
        } catch (SQLException e) {
          fail("Unexpected exception: " + e + " from getJdbcObject()");
          throw new RuntimeException("DUMMY; so compiler know block throws");
        }

        // See if method throws exception:
        method.invoke(jdbcObject, makeArgs(method));

        // If here, method didn't throw--check if it's an expected non-throwing
        // method (e.g., an isClosed).  (If not, report error.)
        final String resultLine = "- " + methodLabel + " didn't throw\n";

        successLinesBuf.append(resultLine);
      } catch (InvocationTargetException wrapperEx) {
        final Throwable cause = wrapperEx.getCause();
        final String resultLine = "- " + methodLabel + " threw <" + cause + ">\n";

        if (SQLException.class.isAssignableFrom(cause.getClass())
            && !AlreadyClosedSqlException.class.isAssignableFrom(cause.getClass())) {
          // Good case--almost any exception should be SQLException or subclass
          // (but make sure not accidentally closed).
          successLinesBuf.append(resultLine);
        } else if (NullPointerException.class == cause.getClass()
            && (method.getName().equals("isWrapperFor") || method.getName().equals("unwrap"))) {
          // Known good-enough case--these methods throw NullPointerException
          // because of the way we call them (with null) and the way Avatica
          // code implements them.
          successLinesBuf.append(resultLine);
        } else if (isOkaySpecialCaseException(method, cause)) {
          successLinesBuf.append(resultLine);
        } else {
          final String badResultLine =
              "- "
                  + methodLabel
                  + " threw <"
                  + cause
                  + "> instead"
                  + " of a "
                  + SQLException.class.getSimpleName()
                  + "\n";
          logger.trace("Failure: " + resultLine);
          failureLinesBuf.append(badResultLine);
        }
      } catch (IllegalAccessException | IllegalArgumentException e) {
        fail("Unexpected exception: " + e + ", cause = " + e.getCause() + "  from " + method);
      }
    }
 /**
  * Obtains an instance of {@code ThrowableDetails}.
  *
  * @param throwable the throwable to create an instance for
  * @return the throwable details instance
  */
 public static ThrowableDetails of(Throwable throwable) {
   ArgumentChecker.notNull(throwable, "throwable");
   String message;
   if (throwable.getMessage() != null) {
     message = throwable.getMessage();
   } else {
     message = throwable.getClass().getSimpleName();
   }
   String stackTrace = Throwables.getStackTraceAsString(throwable);
   return new ThrowableDetails(throwable.getClass(), message, stackTrace);
 }
  /** Assert that the two exceptions have the same message and status. */
  public static void assertEqualThrowables(Throwable e1, Throwable e2) {
    assertEquals(e1.getClass(), e2.getClass());
    assertEquals(e1.getMessage(), e2.getMessage());

    StackTraceElement[] stack1 = e1.getStackTrace();
    StackTraceElement[] stack2 = e2.getStackTrace();
    assertEquals(stack1.length, stack2.length);
    for (int i = 0; i < stack1.length; i++) {
      assertEquals(stack1[i], stack2[i]);
    }
  }
Beispiel #21
0
 public GenericErrorResolver getResolver(Throwable exception) {
   if (exception.getClass().equals(NotAvaliableException.class)) {
     return this.notAvaliableResourceResolver;
   } else if (exception.getClass().equals(InputRequestValidationException.class)) {
     return this.inputRequestValidationResolver;
   } else if (exception.getClass().equals(AccessDeniedException.class)) {
     return this.accessDeniedResolver;
   } else {
     return this.throwableResolver;
   }
 }
Beispiel #22
0
  public static void expectException(Callable<?> callable, Class<?> exception) {
    boolean thrown = false;

    try {
      callable.call();
    } catch (Throwable e) {
      assert e.getClass().equals(exception)
          : e.getClass().getName() + " is not " + exception.getName();
      thrown = true;
    }

    assert thrown : exception.getName() + " not received";
  }
Beispiel #23
0
    public void marshall(PrintWriter wrt, String prefix, Throwable value) {
      String msg = value.getMessage();

      wrt.print(prefix);
      wrt.print("exception.name=");

      if ((msg != null) && (msg.length() > 0)) {
        wrt.print(value.getClass().getName());
        wrt.println(" " + msg);
      } else {
        wrt.println(value.getClass().getName());
      }
    }
Beispiel #24
0
  protected void verifyExceptionInStacktrace(Exception rootExcepton, Class expectedExceptionClass) {
    Throwable expectedException = rootExcepton;
    boolean found = false;
    while (!found && expectedException != null) {
      if (expectedException.getClass().equals(expectedExceptionClass)) {
        found = true;
      } else {
        expectedException = expectedException.getCause();
      }
    }

    assertEquals(expectedExceptionClass, expectedException.getClass());
  }
 private String getFaultNameFromMessage(final Message message) {
   Exception e = message.getContent(Exception.class);
   Throwable cause = e.getCause();
   if (cause == null) {
     cause = e;
   }
   if (e instanceof Fault) {
     WebFault t = cause.getClass().getAnnotation(WebFault.class);
     if (t != null) {
       return t.name();
     }
   }
   return cause.getClass().getSimpleName();
 }
  public BaseExceptionHandler dipacher(Throwable ex) {
    BaseExceptionHandler handler = (BaseExceptionHandler) handleres.get(ex.getClass());
    if (handler == null) {
      handler =
          (BaseExceptionHandler)
              this.handleres.get(findSuperClass(handleres.keySet().iterator(), ex.getClass()));
    }

    if (handler == null) {
      handler = getFallbackExceptionHandler();
    }

    return handler;
  }
  private void init(StackTraceElement[] frames, Throwable throwable, Object... args) {

    int offset = 2;

    if (throwable != null) {
      offset = 0;
    }

    for (int i = offset; i < frames.length; ++i) {

      StackTraceElement frame = frames[i];

      buff.append("\t");
      buff.append(frame.toString());
      buff.append("\n");
    }

    String stacktrace = buff.toString();

    buff = new StringBuffer();

    String tp = Hex.encode(MD5.encode(stacktrace));

    buff.append(String.format("Exception tracepoint: %s", tp));

    if (args.length != 0) buff.append(" (");

    for (int i = 0; i < args.length; i = i + 2) {

      if (i != 0) buff.append(", ");

      buff.append(String.format("%s = %s", args[i], args[i + 1]));
    }

    if (args.length != 0) buff.append(")");

    buff.append("\n");

    if (throwable != null) {

      if (throwable.getMessage() != null) {
        buff.append(
            String.format("%s:%s\n", throwable.getClass().getName(), throwable.getMessage()));
      } else {
        buff.append(String.format("%s\n", throwable.getClass().getName()));
      }
    }

    buff.append(stacktrace);
  }
Beispiel #28
0
 protected String getTitle(Throwable t) {
   String message = t.getMessage();
   String tit = message;
   if (tit == null) {
     StackTraceElement el = t.getStackTrace()[0];
     tit =
         t.getClass().getName().substring(t.getClass().getPackage().getName().length() + 1)
             + " "
             + el.getFileName()
             + ":"
             + el.getLineNumber();
   }
   return tit;
 }
  private void unhandled(Throwable t) {
    TARGET_LOG.warn("Unhandled Error (closing connection)", t);
    onError(t);

    // Unhandled Error, close the connection.
    switch (policy.getBehavior()) {
      case SERVER:
        terminateConnection(StatusCode.SERVER_ERROR, t.getClass().getSimpleName());
        break;
      case CLIENT:
        terminateConnection(StatusCode.POLICY_VIOLATION, t.getClass().getSimpleName());
        break;
    }
  }
  @Override
  public void onUncaughtException(Throwable e) {
    GWT.log("Uncaught Exception", e);
    e = e.getCause();

    String st = e.getClass().getName() + ": " + e.getMessage();
    for (StackTraceElement ste : e.getStackTrace()) {
      st += "\n" + ste.toString();
    }

    LOGGER.severe(st);
    GWT.log(e.getClass().getName() + ": " + e.getMessage(), e);

    ExceptionDialog.show(e);
  }