Throwable toString - 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 toString method.

This code example shows how to use the following methods:toString
    df.parseExecResult(reader);
    try { 
      df.parseOutput();
      fail("Expected exception with missing line!"); 
    } catch (IOException e) {
      GenericTestUtils.assertExceptionContains( 
          "Fewer lines of output than expected", e);
      System.out.println(e.toString());
    } 
     
    reader = new BufferedReader(new StringReader(
        "Filesystem     1K-blocks     Used Available Use% Mounted on\n" + 
        " ")); 
    df.parseExecResult(reader);
    try { 
      df.parseOutput();
      fail("Expected exception with empty line!"); 
    } catch (IOException e) {
      GenericTestUtils.assertExceptionContains("Unexpected empty line", e);
      System.out.println(e.toString());

8
CodeRank
This code example shows how to use the following methods:toString
        try { 
            conn = Support_SQL.getConnection();
            statement = conn.createStatement();
            createTestTables(); 
        } catch (SQLException e) {
            fail("Unexpected SQLException " + e.toString());
        } 
        DatabaseCreator.fillParentTable(conn);
        DatabaseCreator.fillSimpleTable3(conn);
        DatabaseCreator.fillSimpleTable1(conn);
    } 
 
    public void tearDown() throws Exception { 
        deleteTestTables(); 
        statement.close();
        conn.close();
        super.tearDown(); 
    } 
 
    private void createTestTables() { 
7
CodeRank
This code example shows how to use the following methods:toString
                SimpleDateFormat sdf = new SimpleDateFormat(I18N.getDateFormat());
                sdf.setLenient(false);
                cal.setTime(sdf.parse(value));
            } 
        } catch (ParseException e) {
            throw new IllegalArgumentException("Cannot convert [" + value + "] to a Calendar: " + e.toString());
        } 
 
        return cal;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:toString
            if (document == null) {
                document = DomBuilder.build(getResult());
            } 
            return document;
        } catch (ParserConfigurationException e) {
            LOGGER.error(e);
            throw new RuntimeException(e.toString());
        } 
    } 
 
    /** 
     * Returns the {@link Query}. If you modify the query, call 
     * <code>{@link #setDirty}(true)</code>. 
     */ 
    public Query getQuery() { 
        return query;
    } 
 
    /** 
     * Sets the query. Automatically calls <code>{@link #setDirty}(true)</code>. 
7
CodeRank
This code example shows how to use the following methods:toString
    ObjectInputStream in;
    try { 
      in = new ObjectInputStream(source);
      mappingFileProvider.readExternal(in);
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, e.toString());
    } 
  } 
 
  private AreaCodeMap getPhonePrefixDescriptions( 
      int countryCallingCode, String language, String script, String region) {
    String fileName = mappingFileProvider.getFileName(countryCallingCode, language, script, region);
    if (fileName.length() == 0) {
      return null; 
    } 
    if (!availablePhonePrefixMaps.containsKey(fileName)) {
      loadAreaCodeMapFromFile(fileName);
    } 
    return availablePhonePrefixMaps.get(fileName);
  } 
7
CodeRank
This code example shows how to use the following methods:toString
    private void handleBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel) throws OperationFailedException {
        context.removeService(SOCKET_BINDING.append(bindingName));
        try { 
            BindingAddHandler.installBindingService(context, bindingModel, bindingName, null);
        } catch (UnknownHostException e) {
            throw new OperationFailedException(new ModelNode().set(e.toString()));
        } 
    } 
 
    private void revertBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel,
                                        String attributeName, ModelNode previousValue) {
        context.removeService(SOCKET_BINDING.append(bindingName));
        ModelNode unresolvedConfig = bindingModel.clone();
        unresolvedConfig.get(attributeName).set(previousValue);
        try { 
            BindingAddHandler.installBindingService(context, unresolvedConfig, bindingName, null);
        } catch (Exception e) {
            // Bizarro, as we installed the service before 
            throw new RuntimeException(e);
        } 
7
CodeRank
This code example shows how to use the following methods:toString
        try { 
            conn = Support_SQL.getConnection();
            statement = conn.createStatement();
            createTestTables(); 
        } catch (SQLException e) {
            fail("Unexpected SQLException " + e.toString());
        } 
    } 
 
    public void tearDown() throws Exception { 
        deleteTestTables(); 
        conn.close();
        statement.close();
        super.tearDown(); 
    } 
 
    private void createTestTables() { 
        try { 
            ResultSet userTab = conn.getMetaData().getTables(null,
                    null, null, null); 
7
CodeRank
This code example shows how to use the following methods:toString
  public void connect() throws IOException { 
    try { 
      FileSystem fs = FileSystem.get(url.toURI(), conf);
      is = fs.open(new Path(url.getPath()));
    } catch (URISyntaxException e) {
      throw new IOException(e.toString());
    } 
  } 
 
  @Override 
  public InputStream getInputStream() throws IOException {
    if (is == null) {
      connect(); 
    } 
    return is;
  } 
 
} 
7
CodeRank
This code example shows how to use the following methods:toString
				System.out.println("SERVER inbound data port " + this.serverSocket.getLocalPort()
						+ " is ready and waiting for client to connect..."); 
			} 
		} catch (SocketException se) {
			System.err.println("Unable to create socket.");
			System.err.println(se.toString());
			System.exit(1);
		} catch (IOException ioe) {
			System.err.println("Unable to read data from an open socket.");
			System.err.println(ioe.toString());
			System.exit(1);
		} 
	} 
 
	/** 
	 * Run this class as an application. 
	 */ 
	public static void main(String[] args) {
		new TcpServer(); 
	} 
6
CodeRank
This code example shows how to use the following methods:toString
      byte[] bytes = Base64.decodeBase64(str.getBytes("UTF-8"));
      inBuf.reset(bytes, bytes.length);
      T restored = deserializer.deserialize(null);
      return restored;
    } catch (UnsupportedCharsetException ex) {
      throw new IOException(ex.toString());
    } 
  } 
 
  @Override 
  public String toString(T obj) throws IOException {
    outBuf.reset();
    serializer.serialize(obj);
    byte[] buf = new byte[outBuf.getLength()];
    System.arraycopy(outBuf.getData(), 0, buf, 0, buf.length);
    return new String(Base64.encodeBase64(buf));
  } 
 
  @Override 
  public void close() throws IOException { 
6
CodeRank

Related Throwable toString Questions & Answers:

Other Throwable toString Examples

97:				response = sb.toString();
98:			} catch (Exception e) {
99:				Log.e("Buffer Error", "Error: " + e.toString());
100:			}
101:

Read More

82:				json = sb.toString();
83:			} catch (Exception e) {
84:				Log.e("Buffer Error", "Error converting result " + e.toString());
85:			}
86:

Read More

83:			} catch (Exception e) {
84:				Log.e("Buffer Error", "Error converting result " + e.toString());
85:			}
86:	
87:			// try parse the string to a JSON object
-
90:			} catch (JSONException e) {
91:				Log.e("JSON Parser", "Error parsing data " + e.toString());
92:			}
93:	
94:			// return JSON String

Read More

toString Method Overview
Returns a short description of this throwable.
See Code Examples for other Java 8 Throwable Methods: