congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Exception.toString
Code IndexAdd Tabnine to your IDE (free)

How to use
toString
method
in
java.lang.Exception

Best Java code snippets using java.lang.Exception.toString (Showing top 20 results out of 29,331)

origin: jenkinsci/jenkins

public String getShortDescription() {
  return cause.toString();
}
origin: redisson/redisson

  public String toString() {
    if (e == null)
      return super.toString();
    else
      return e.toString();
  }
}
origin: redisson/redisson

  public CannotCreateException(Exception e) {
    super("by " + e.toString());
  }
}
origin: redisson/redisson

  public ObjectNotFoundException(String name, Exception e) {
    super(name + " because of " + e.toString());
  }
}
origin: redisson/redisson

  public RemoteException(Exception e) {
    super("by " + e.toString());
  }
}
origin: redisson/redisson

  public NotFoundException(String msg, Exception e) {
    super(msg + " because of " + e.toString());
  }
}
origin: log4j/log4j

 /**
   Render the object passed as parameter by calling its
   <code>toString</code> method.  */
 public
 String doRender(final Object o) {
     try {
      return o.toString();
     } catch(Exception ex) {
      return ex.toString();
     }
 }
}  
origin: neo4j/neo4j

@Override
public String toString()
{
  StringWriter result = new StringWriter().append( super.toString() );
  for ( Diagnostic<?> diagnostic : diagnostics )
  {
    format( result.append( "\n\t\t" ), diagnostic );
  }
  return result.toString();
}
origin: apache/incubator-dubbo

private void introspectWriteReplace(Class cl, ClassLoader loader) {
  try {
    String className = cl.getName() + "HessianSerializer";
    Class serializerClass = Class.forName(className, false, loader);
    Object serializerObject = serializerClass.newInstance();
    Method writeReplace = getWriteReplace(serializerClass, cl);
    if (writeReplace != null) {
      _writeReplaceFactory = serializerObject;
      _writeReplace = writeReplace;
      return;
    }
  } catch (ClassNotFoundException e) {
  } catch (Exception e) {
    log.log(Level.FINER, e.toString(), e);
  }
  _writeReplace = getWriteReplace(cl);
}
origin: apache/incubator-dubbo

private void introspectWriteReplace(Class cl, ClassLoader loader) {
  try {
    String className = cl.getName() + "HessianSerializer";
    Class serializerClass = Class.forName(className, false, loader);
    Object serializerObject = serializerClass.newInstance();
    Method writeReplace = getWriteReplace(serializerClass, cl);
    if (writeReplace != null) {
      _writeReplaceFactory = serializerObject;
      _writeReplace = writeReplace;
      return;
    }
  } catch (ClassNotFoundException e) {
  } catch (Exception e) {
    log.log(Level.FINER, e.toString(), e);
  }
  _writeReplace = getWriteReplace(cl);
}
origin: spring-projects/spring-framework

@Override
@Nullable
public String getMessage() {
  if (ObjectUtils.isEmpty(this.messageExceptions)) {
    return super.getMessage();
  }
  else {
    StringBuilder sb = new StringBuilder();
    String baseMessage = super.getMessage();
    if (baseMessage != null) {
      sb.append(baseMessage).append(". ");
    }
    sb.append("Failed messages: ");
    for (int i = 0; i < this.messageExceptions.length; i++) {
      Exception subEx = this.messageExceptions[i];
      sb.append(subEx.toString());
      if (i < this.messageExceptions.length - 1) {
        sb.append("; ");
      }
    }
    return sb.toString();
  }
}
origin: spring-projects/spring-framework

/**
 * Build a descriptive exception message for the given JMSException,
 * incorporating a linked exception's message if appropriate.
 * @param ex the JMSException to build a message for
 * @return the descriptive message String
 * @see javax.jms.JMSException#getLinkedException()
 */
public static String buildExceptionMessage(JMSException ex) {
  String message = ex.getMessage();
  Exception linkedEx = ex.getLinkedException();
  if (linkedEx != null) {
    if (message == null) {
      message = linkedEx.toString();
    }
    else {
      String linkedMessage = linkedEx.getMessage();
      if (linkedMessage != null && !message.contains(linkedMessage)) {
        message = message + "; nested exception is " + linkedEx;
      }
    }
  }
  return message;
}
origin: redisson/redisson

/**
 * Obtains the default value represented by this attribute.
 */
public MemberValue getDefaultValue()
{
  try {
    return new AnnotationsAttribute.Parser(info, constPool)
                   .parseMemberValue();
  }
  catch (Exception e) {
    throw new RuntimeException(e.toString());
  }
}
origin: spring-projects/spring-framework

private void assertIsCompiled(Expression expression) {
  try {
    Field field = SpelExpression.class.getDeclaredField("compiledAst");
    field.setAccessible(true);
    Object object = field.get(expression);
    assertNotNull(object);
  }
  catch (Exception ex) {
    fail(ex.toString());
  }
}
origin: ReactiveX/RxJava

/**
 * Validates that the given class, when forcefully instantiated throws
 * an IllegalArgumentException("No instances!") exception.
 * @param clazz the class to test, not null
 */
public static void checkUtilityClass(Class<?> clazz) {
  try {
    Constructor<?> c = clazz.getDeclaredConstructor();
    c.setAccessible(true);
    try {
      c.newInstance();
      fail("Should have thrown InvocationTargetException(IllegalStateException)");
    } catch (InvocationTargetException ex) {
      assertEquals("No instances!", ex.getCause().getMessage());
    }
  } catch (Exception ex) {
    AssertionError ae = new AssertionError(ex.toString());
    ae.initCause(ex);
    throw ae;
  }
}
origin: commons-io/commons-io

@Test
public void testIncorrectOutputSize() throws Exception {
  final File inFile = new File("pom.xml");
  final File outFile = new ShorterFile("target/pom.tmp"); // it will report a shorter file
  try {
    FileUtils.copyFile(inFile, outFile);
    fail("Expected IOException");
  } catch (final Exception e) {
    final String msg = e.toString();
    assertTrue(msg, msg.contains("Failed to copy full contents"));
  } finally {
    outFile.delete(); // tidy up
  }
}
origin: apache/zookeeper

@Test
public void testTripleElection() throws Exception {
  try{
    runElection(3);
  } catch (Exception e) {
    Assert.fail(e.toString());
  }
}
origin: apache/zookeeper

@Test
public void testSingleElection() throws Exception {
  try{
    runElection(1);
  } catch (Exception e) {
    Assert.fail(e.toString());
  }
}

origin: spring-projects/spring-framework

private ClientHttpResponse getClientHttpResponse(
    HttpMethod httpMethod, URI uri, HttpHeaders requestHeaders, byte[] requestBody) {
  try {
    MockHttpServletResponse servletResponse = this.mockMvc
        .perform(request(httpMethod, uri).content(requestBody).headers(requestHeaders))
        .andReturn()
        .getResponse();
    HttpStatus status = HttpStatus.valueOf(servletResponse.getStatus());
    byte[] body = servletResponse.getContentAsByteArray();
    MockClientHttpResponse clientResponse = new MockClientHttpResponse(body, status);
    clientResponse.getHeaders().putAll(getResponseHeaders(servletResponse));
    return clientResponse;
  }
  catch (Exception ex) {
    byte[] body = ex.toString().getBytes(StandardCharsets.UTF_8);
    return new MockClientHttpResponse(body, HttpStatus.INTERNAL_SERVER_ERROR);
  }
}
origin: spring-projects/spring-framework

@Test  // SPR-16132
public void followUpRequestAfterFailure() {
  MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build();
  server.expect(requestTo("/some-service/some-endpoint"))
      .andRespond(request -> { throw new SocketException("pseudo network error"); });
  server.expect(requestTo("/reporting-service/report-error"))
      .andExpect(method(POST)).andRespond(withSuccess());
  try {
    this.restTemplate.getForEntity("/some-service/some-endpoint", String.class);
  }
  catch (Exception ex) {
    this.restTemplate.postForEntity("/reporting-service/report-error", ex.toString(), String.class);
  }
  server.verify();
}
java.langExceptiontoString

Popular methods of Exception

  • getMessage
  • printStackTrace
  • <init>
    Constructs a new exception with the specified cause and a detail message of (cause==null ? null : c
  • getCause
  • getLocalizedMessage
  • getStackTrace
  • addSuppressed
  • initCause
  • fillInStackTrace
  • setStackTrace
  • getSuppressed
  • logWithStack
  • getSuppressed,
  • logWithStack

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • setContentView (Activity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • JCheckBox (javax.swing)
  • JPanel (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now