Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.steveash.bushwhacker;
 
 import java.util.List;
 
 import static com.google.common.base.Throwables.getCausalChain;
 import static com.google.common.collect.Lists.reverse;

Handles a chain of exceptions by invoking the ExceptionHandler for each; this is _not_ an ExceptionHandler because it handles causal chains whereas an ExceptionHandler is not supposed to. So its not substitutable and thus not in an IS A relationship.

Author(s):
Steve Ash
  public DefaultExceptionChainHandler(ExceptionHandler perExceptionHandler) {
    this. = perExceptionHandler;
  }
  public boolean handle(Throwable t) {
    List<ThrowablerootToTop = reverse(getCausalChain(t));
    boolean anyHandled = false;
    for (int i = 0; i < rootToTop.size(); i++) {
      if (.handle(t)) {
        anyHandled = true;
      }
    }
    return anyHandled;
  }
New to GrepCode? Check out our FAQ X