### Question:
SqlHandler extends XRayHandler { @Override public void handleResponse(Event event) { if (decrementSqlTransactionCount() > 0) { return; } Subsegment subsegment = getSubsegment(); ServiceDownstreamResponseEvent responseEvent = (ServiceDownstreamResponseEvent) event; Throwable thrown = responseEvent.getThrown(); if (thrown != null) { subsegment.addException(thrown); } endSubsegment(); }  @Override void handleRequest(Event event); @Override void handleResponse(Event event);  }### Answer:
@Test public void testSubsegmentEndedWithThrowable() { XRaySDKConfiguration.getInstance().init(); Segment seg = AWSXRay.beginSegment("test"); Subsegment sub = AWSXRay.beginSubsegment("FakeSqlSub"); TransactionContext.putMetadata(SqlHandler.SQL_SUBSEGMENT_COUNT_KEY, 1); handler.handleResponse(responseEvent); assertThat(seg.getSubsegments().size()).isEqualTo(1); assertThat(sub.isInProgress()).isFalse(); assertThat(sub.getCause().getExceptions().size()).isEqualTo(1); assertThat(sub.isFault()).isTrue(); }