Throwable initCause - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Throwable initCause method.

This code example shows how to use the following methods:initCause, setStackTrace
  throws IOException { 
    String decodedFileName = null;
    try { 
      decodedFileName = URLDecoder.decode(logFileName, "UTF-8");
    } catch (UnsupportedEncodingException uee) {
      IOException ioe = new IOException();
      ioe.initCause(uee);
      ioe.setStackTrace(uee.getStackTrace());
      throw ioe;
    } 
    return decodedFileName;
  } 
   
  static String nonOccursString(String logFileName) {
    int adHocIndex = 0;
 
    String unfoundString = "q" + adHocIndex;
 
    while (logFileName.contains(unfoundString)) {
      unfoundString = "q" + ++adHocIndex;
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
    if (writableClass != null)
      return writableClass.asSubclass(Writable.class);
    try { 
      return conf.getClassByName(name);
    } catch (ClassNotFoundException e) {
      IOException newE = new IOException("WritableName can't load class: " + name);
      newE.initCause(e);
      throw newE;
    } 
  } 
 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
            mRealOwner = realOwner;
            Class<?> c = realOwner.getClass();
            try { 
                mMethod = c.getMethod(methodName, PARAM_TYPES);
            } catch (Exception e) {
                InflateException ex = new InflateException(
                        "Couldn't resolve menu item onClick handler " + methodName +
                        " in class " + c.getName());
                ex.initCause(e);
                throw ex;
            } 
        } 
 
        public boolean onMenuItemClick(MenuItem item) {
            try { 
                if (mMethod.getReturnType() == Boolean.TYPE) {
                    return (Boolean) mMethod.invoke(mRealOwner, item);
                } else { 
                    mMethod.invoke(mRealOwner, item);
                    return true; 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
        } catch (IOException e) {
            LoginException le = new LoginException("Failed to get username/password");
            le.initCause(e);
            throw le;
        } catch (UnsupportedCallbackException e) {
            LoginException le = new LoginException("CallbackHandler does not support: " + e.getCallback());
            le.initCause(e);
            throw le;
        } 
        info[0] = username;
        info[1] = password;
        return info;
    } 
 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
                throw new IllegalArgumentException();
             
            return fd;
        } catch(IllegalArgumentException error)
        { 
            FileNotFoundException fileError = new FileNotFoundException("Cannot assign file for URI: " + uri.toString());
            fileError.initCause(error);
            throw fileError;
        } 
    } 
 
    @Override 
    public boolean onCreate() { 
        return true; 
    } 
 
    @Override 
    public int delete(Uri uri, String s, String[] as) {
        throw new UnsupportedOperationException(
                "Delete operation is not supported by this provider"); 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
        } catch (IOException e) {
            LoginException le = new LoginException("Failed to get username/password");
            le.initCause(e);
            throw le;
        } catch (UnsupportedCallbackException e) {
            LoginException le = new LoginException("CallbackHandler does not support: " + e.getCallback());
            le.initCause(e);
            throw le;
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
            mRealOwner = realOwner;
            Class<?> c = realOwner.getClass();
            try { 
                mMethod = c.getMethod(methodName, PARAM_TYPES);
            } catch (Exception e) {
                InflateException ex = new InflateException(
                        "Couldn't resolve menu item onClick handler " + methodName +
                        " in class " + c.getName());
                ex.initCause(e);
                throw ex;
            } 
        } 
 
        public boolean onMenuItemClick(MenuItem item) {
            try { 
                if (mMethod.getReturnType() == Boolean.TYPE) {
                    return (Boolean) mMethod.invoke(mRealOwner, item);
                } else { 
                    mMethod.invoke(mRealOwner, item);
                    return true; 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
    public static IOException wrap(final Throwable e) {
        return wrap(e.getMessage(), e);
    } 
     
    public static IOException wrap(final String message, final Throwable e) {
        final IOException wrappedException = new IOException(message);
        wrappedException.initCause(e);
        return wrappedException;
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
     * </p> 
     */ 
    public void testJdk7ipv6() 
    { 
        ConnectException connEx = new ConnectException( "Connection refused: connect" );
        IOException ioEx = new IOException( "Unable to establish loopback connection" );
        ioEx.initCause( connEx );
        MojoExecutionException mojoEx =
            new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx );
 
        ExceptionHandler exceptionHandler = new DefaultExceptionHandler();
        ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx );
 
        String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException";
        assertEquals( expectedReference, exceptionSummary.getReference() );
 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:initCause
  private IOException instantiateException(Class<? extends IOException> cls)
      throws Exception { 
    Constructor<? extends IOException> cn = cls.getConstructor(String.class);
    cn.setAccessible(true);
    IOException ex = cn.newInstance(this.getMessage());
    ex.initCause(this);
    return ex;
  } 
 
  /** Create RemoteException from attributes */ 
  public static RemoteException valueOf(Attributes attrs) {
    return new RemoteException(attrs.getValue("class"),
        attrs.getValue("message")); 
  } 
 
  @Override 
  public String toString() {
    return getClass().getName() + "(" + className + "): " + getMessage();
  } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Throwable initCause Questions & Answers:

initCause Method Overview
Initializes the cause of this throwable to the specified value.
See Code Examples for other Java 8 Throwable Methods: