private void enhanceFailureWithSeed( Throwable t ) { Exceptions.withMessage( t, t.getMessage() + ": random seed used:" + seed + "L" ); } };
private <E extends Throwable> void appendTreeInformation( E e ) { Exceptions.withMessage( e, e.getMessage() + " | " + toString() ); }
private OutOfMemoryError error( long length, int itemSize, OutOfMemoryError error ) { return Exceptions.withMessage( error, format( "%s: Not enough memory available for allocating %s, tried %s", error.getMessage(), bytes( length * itemSize ), Arrays.toString( candidates ) ) ); }
static void assertExceptionContains( Exception e, String message, Class<? extends Exception> type ) throws Exception { if ( !contains( e, message, type ) ) { // Rethrow the exception since we'd like to see what it was instead throw withMessage( e, format( "Expected exception to contain cause '%s', %s. but was %s", message, type, e ) ); } }
@Override public void distribute( RelationshipRecord relationship, RecordConsumer<RelationshipRecord> consumer ) throws InterruptedException { int qIndex1 = (int) Math.min( maxAvailableThread, Math.abs( relationship.getFirstNode() ) / recordsPerCpu ); int qIndex2 = (int) Math.min( maxAvailableThread, Math.abs( relationship.getSecondNode() ) / recordsPerCpu ); try { consumer.accept( relationship, qIndex1 ); if ( qIndex1 != qIndex2 ) { consumer.accept( relationship, qIndex2 ); } } catch ( ArrayIndexOutOfBoundsException e ) { throw Exceptions.withMessage( e, e.getMessage() + ", recordsPerCPU:" + recordsPerCpu + ", relationship:" + relationship + ", number of threads: " + numberOfThreads ); } } }
private void collect( ProblemReporter report ) { boolean collect = collects( report.type() ); if ( collect ) { // This type of problem is collected and we're within the max threshold, so it's OK long count = badEntries.incrementAndGet(); if ( tolerance == UNLIMITED_TOLERANCE || count <= tolerance ) { // We're within the threshold if ( logBadEntries ) { // Send this to the logger... but first apply some back pressure if queue is growing big while ( queueSize.sum() >= backPressureThreshold ) { LockSupport.parkNanos( TimeUnit.MILLISECONDS.toNanos( 10 ) ); } logger.send( report ); queueSize.add( 1 ); } return; // i.e. don't treat this as an exception } } InputException exception = report.exception(); throw collect ? withMessage( exception, format( "Too many bad entries %d, where last one was: %s", badEntries.longValue(), exception.getMessage() ) ) : exception; }
withMessage( t, t.getMessage() + " | " + format( "GBPTree[file:%s]", indexFile ) ); throw t;
@Test void shouldSetMessage() { // GIVEN String initialMessage = "Initial message"; LevelOneException exception = new LevelOneException( initialMessage ); // WHEN String prependedMessage = "Prepend this: " + exception.getMessage(); Exceptions.withMessage( exception, prependedMessage ); // THEN assertEquals( prependedMessage, exception.getMessage() ); }
e = withMessage( e, e.getMessage() + ". At position " + position + " and entry version " + version );
throw Exceptions.withMessage( e, message );
private void enhanceFailureWithSeed( Throwable t ) { Exceptions.withMessage( t, t.getMessage() + ": random seed used:" + seed + "L" ); } };
private <E extends Throwable> void appendTreeInformation( E e ) { Exceptions.withMessage( e, e.getMessage() + " | " + toString() ); }
private OutOfMemoryError error( long length, int itemSize, OutOfMemoryError error ) { return Exceptions.withMessage( error, format( "%s: Not enough memory available for allocating %s, tried %s", error.getMessage(), bytes( length * itemSize ), Arrays.toString( candidates ) ) ); }
private void collect( ProblemReporter report ) { boolean collect = collects( report.type() ); if ( collect ) { // This type of problem is collected and we're within the max threshold, so it's OK long count = badEntries.incrementAndGet(); if ( tolerance == UNLIMITED_TOLERANCE || count <= tolerance ) { // We're within the threshold if ( logBadEntries ) { // Send this to the logger logger.send( report ); } return; // i.e. don't treat this as an exception } } InputException exception = report.exception(); throw collect ? withMessage( exception, format( "Too many bad entries %d, where last one was: %s", badEntries.longValue(), exception.getMessage() ) ) : exception; }
withMessage( t, t.getMessage() + " | " + format( "GBPTree[file:%s]", indexFile ) ); throw t;
e = withMessage( e, e.getMessage() + ". At position " + position + " and entry version " + version );
throw Exceptions.withMessage( e, message );