/** * Initializes the cause of this exception to the specified value. * * @param cause The cause of this exception. * @return This exception. * @throws IllegalArgumentException If the specified cause is this * exception. * @throws IllegalStateException If the cause of this exception has already * been set. */ public Throwable initCause(Throwable cause) { return super.initCause(cause); } }
public UnknownUnwrapTypeException(Class unwrapType, Throwable root) { this( unwrapType ); super.initCause( root ); }
public String firstLine(BufferedReader r) { try { return r.readLine(); } catch (IOException e) { throw (RuntimeException) new RuntimeException("IO Error").initCause(e); } }
/** * Generates XML and writes it to the given <code>PrintWriter</code> */ private void generate(PrintWriter pw) { // Use JAXP's transformation API to turn SAX events into pretty // XML text try { Source src = new SAXSource(this, new InputSource()); Result res = new StreamResult(pw); TransformerFactory xFactory = TransformerFactory.newInstance(); Transformer xform = xFactory.newTransformer(); xform.setOutputProperty(OutputKeys.METHOD, "xml"); xform.setOutputProperty(OutputKeys.INDENT, "yes"); xform.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, SYSTEM_ID); xform.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, PUBLIC_ID); xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); xform.transform(src, res); pw.flush(); } catch (Exception ex) { RuntimeException ex2 = new RuntimeException( "Exception thrown while generating XML."); ex2.initCause(ex); throw ex2; } }
private static <T> T getFuture(final String comment, final Future<T> future) { try { return Uninterruptibles.getUninterruptibly(future); // No need to catch cancellationexception - we never cancel these futures } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof SQLiteException) { final RuntimeException sqlException = getSqliteException("Cannot " + comment, ((SQLiteException) t).getBaseErrorCode()); sqlException.initCause(e); throw sqlException; } else { throw new RuntimeException(e); } } }
/** * Writes the generator's state to pw */ private void generate(PrintWriter pw) { // Use JAXP's transformation API to turn SAX events into pretty // XML text try { Source src = new SAXSource(this, new InputSource()); Result res = new StreamResult(pw); TransformerFactory xFactory = TransformerFactory.newInstance(); Transformer xform = xFactory.newTransformer(); xform.setOutputProperty(OutputKeys.METHOD, "xml"); xform.setOutputProperty(OutputKeys.INDENT, "yes"); if (!useSchema) { // set the doctype system and public ids from version for older DTDs. xform.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, version.getSystemId()); xform.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, version.getPublicId()); } xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); xform.transform(src, res); pw.flush(); } catch (Exception ex) { RuntimeException ex2 = new RuntimeException( "An Exception was thrown while generating XML."); ex2.initCause(ex); throw ex2; } }
", but in the past before"; RuntimeException ex = new RuntimeException(message); ex.initCause(e); ex.printStackTrace(System.out);
/** {@inheritDoc} */ @Override public T get() throws ExecutionException { try { T res = fut.get(); if (fut.isCancelled()) throw new CancellationException("Task was cancelled: " + fut); return res; } catch (IgniteCheckedException e) { // Task cancellation may cause throwing exception. if (fut.isCancelled()) { RuntimeException ex = new CancellationException("Task was cancelled: " + fut); ex.initCause(e); throw ex; } throw new ExecutionException("Failed to get task result: " + fut, e); } }
public int calcSerializedSize() { NullDataOutputStream dos = new NullDataOutputStream(); try { toData(dos); return dos.size(); } catch (IOException ex) { RuntimeException ex2 = new IllegalArgumentException( "Could not calculate size of object"); ex2.initCause(ex); throw ex2; } }
LOG.warn("Caught: " + e, e); throw (RuntimeException) new RuntimeException(e.getMessage()). initCause(e); } finally { if (callback != null) {
LOG.warn("Caught: " + e, e); throw (RuntimeException) new RuntimeException(e.getMessage()). initCause(e);
/** {@inheritDoc} */ @Override public T get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException { A.ensure(timeout >= 0, "timeout >= 0"); A.notNull(unit, "unit != null"); try { T res = fut.get(unit.toMillis(timeout)); if (fut.isCancelled()) throw new CancellationException("Task was cancelled: " + fut); return res; } catch (IgniteFutureTimeoutCheckedException e) { TimeoutException e2 = new TimeoutException(); e2.initCause(e); throw e2; } catch (ComputeTaskTimeoutCheckedException e) { throw new ExecutionException("Task execution timed out during waiting for task result: " + fut, e); } catch (IgniteCheckedException e) { // Task cancellation may cause throwing exception. if (fut.isCancelled()) { RuntimeException ex = new CancellationException("Task was cancelled: " + fut); ex.initCause(e); throw ex; } throw new ExecutionException("Failed to get task result.", e); } } }
@Override public boolean containsValueForKey(KeyInfo keyInfo) { try { boolean retVal = region.containsValueForKeyRemotely( (InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey()); trackBucketForTx(keyInfo); return retVal; } catch (TransactionException e) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e.getCause()); throw re; } catch (PrimaryBucketException e) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e); throw re; } catch (ForceReattemptException e) { if (isBucketNotFoundException(e)) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e); throw re; } waitToRetry(); RuntimeException re = new TransactionDataNodeHasDepartedException( String.format( "Transaction data node %s has departed. To proceed, rollback this transaction and begin a new one.", state.getTarget())); re.initCause(e); throw re; } }
@Override public boolean containsKey(KeyInfo keyInfo) { try { boolean retVal = region.containsKeyRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey()); trackBucketForTx(keyInfo); return retVal; } catch (TransactionException e) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e.getCause()); throw re; } catch (PrimaryBucketException e) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e); throw re; } catch (ForceReattemptException e) { if (isBucketNotFoundException(e)) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e); throw re; } waitToRetry(); RuntimeException re = new TransactionDataNodeHasDepartedException( String.format( "Transaction data node %s has departed. To proceed, rollback this transaction and begin a new one.", state.getTarget())); re.initCause(e); throw re; } }
public void run() { try { servers.add(ServerTestUtils.startVoldemortServer(socketStoreFactory, ServerTestUtils.createServerConfig(useNio, j, TestUtils.createTempDir() .getAbsolutePath(), null, storesXmlfile, props), cluster)); } catch(IOException ioe) { logger.error("Caught IOException during parallel server start: " + ioe.getMessage()); RuntimeException re = new RuntimeException(); re.initCause(ioe); throw re; } finally { // Ensure setup progresses in face of errors countDownLatch.countDown(); } } });
@Override public boolean putEntry(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue, long lastModified, boolean overwriteDestroyed) { boolean retVal = false; final InternalRegion r = event.getRegion(); PartitionedRegion pr = (PartitionedRegion) r; try { retVal = pr.putRemotely(state.getTarget(), event, ifNew, ifOld, expectedOldValue, requireOldValue); } catch (TransactionException e) { RuntimeException re = getTransactionException(event.getKeyInfo(), e); re.initCause(e.getCause()); throw re; } catch (PrimaryBucketException e) { RuntimeException re = getTransactionException(event.getKeyInfo(), e); re.initCause(e); throw re; } catch (ForceReattemptException e) { waitToRetry(); RuntimeException re = getTransactionException(event.getKeyInfo(), e); re.initCause(e); throw re; } trackBucketForTx(event.getKeyInfo()); return retVal; }
} catch (TransactionException e) { RuntimeException re = getTransactionException(event.getKeyInfo(), e); re.initCause(e.getCause()); throw re; } catch (PrimaryBucketException e) { RuntimeException re = getTransactionException(event.getKeyInfo(), e); re.initCause(e); throw re; } catch (ForceReattemptException e) { state.getTarget())); re.initCause(e); waitToRetry(); throw re;
@Override public RuntimeException generateCancelledException(Throwable e) { String reason = cancelInProgress(); if (reason == null) { return null; } DistributionManager dm = getDM(); if (dm == null) { return new DistributedSystemDisconnectedException("no distribution manager"); } RuntimeException result = dm.getCancelCriterion().generateCancelledException(e); if (result != null) { return result; } // We know we've been stopped; generate the exception result = new DistributedSystemDisconnectedException("Conduit has been stopped"); result.initCause(e); return result; } }
private VersionedObjectList sendMsgByBucket(final Integer bucketId, RemoveAllPRMessage prMsg, PartitionedRegion pr) { // retry the put remotely until it finds the right node managing the bucket InternalDistributedMember currentTarget = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null); if (!currentTarget.equals(this.state.getTarget())) { @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr); try { throw new TransactionDataNotColocatedException( String.format("Key %s is not colocated with transaction", firstEvent.getKey())); } finally { firstEvent.release(); } } try { return pr.tryToSendOneRemoveAllMessage(prMsg, currentTarget); } catch (ForceReattemptException prce) { pr.checkReadiness(); throw new TransactionDataNotColocatedException(prce.getMessage()); } catch (PrimaryBucketException notPrimary) { RuntimeException re = new TransactionDataRebalancedException( "Transactional data moved, due to rebalancing."); re.initCause(notPrimary); throw re; } catch (DataLocationException dle) { throw new TransactionException(dle); } }
private VersionedObjectList sendMsgByBucket(final Integer bucketId, PutAllPRMessage prMsg, PartitionedRegion pr) { // retry the put remotely until it finds the right node managing the bucket InternalDistributedMember currentTarget = pr.getOrCreateNodeForBucketWrite(bucketId.intValue(), null); if (!currentTarget.equals(this.state.getTarget())) { @Released EntryEventImpl firstEvent = prMsg.getFirstEvent(pr); try { throw new TransactionDataNotColocatedException( String.format("Key %s is not colocated with transaction", firstEvent.getKey())); } finally { firstEvent.release(); } } try { return pr.tryToSendOnePutAllMessage(prMsg, currentTarget); } catch (ForceReattemptException prce) { pr.checkReadiness(); throw new TransactionDataNotColocatedException(prce.getMessage()); } catch (PrimaryBucketException notPrimary) { RuntimeException re = new TransactionDataRebalancedException( "Transactional data moved, due to rebalancing."); re.initCause(notPrimary); throw re; } catch (DataLocationException dle) { throw new TransactionException(dle); } }