[ 
https://issues.jboss.org/browse/SEAMCATCH-4?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12569367#comment-12569367
 ] 

Dan Allen commented on SEAMCATCH-4:
-----------------------------------

Here are some examples.

1. Drop all frames in NoDefClassFoundError

public class NoClassFoundStackFrameFilter implements 
ExceptionStackFrameFilter<NoClassDefFoundError>
{
   @Override
   public StackFrameFilterResult process(StackFrame frame)
   {
      return StackFrameFilterResult.BREAK;
   }
}

2. Truncate frames after a threshold (though no indication we did that we did)

public class TruncateExceptionStackFilter implements 
ExceptionStackFrameFilter<Throwable>
{
   @Override
   public StackFrameFilterResult process(StackFrame frame)
   {
      if (frame.getIterationStatus().getIndex() >= 20)
      {
         return StackFrameFilterResult.DROP_REMAINING;
      }
      
      return StackFrameFilterResult.INCLUDE;
   }
}

3. Remove noise in between fire event and invoke observer

public class InvokeObserverStackFrameFilter implements 
ExceptionStackFrameFilter<Throwable>
{
   @Override
   public StackFrameFilterResult process(StackFrame frame)
   {
      StackTraceElement el = frame.getStackTraceElement();
      if (frame.isMarkSet("event.firing"))
      {
        if (isReflectionInvoke(el))
         {
            frame.clearMark("event.firing");
            return StackFrameFilterResult.DROP;
         }
        else
         {
            return StackFrameFilterResult.DROP;
         }
      }
      else if (el.getClassName().contains(".BeanManager") && 
el.getMethodName().equals("fireEvent"))
      {
         frame.mark("event.firing");
         return StackFrameFilterResult.INCLUDE;
      }
      
      return StackFrameFilterResult.INCLUDE;
   }
   
   private boolean isReflectionInvoke(StackTraceElement candidate)
   {
      return candidate.getClassName().equals(Method.class.getName())
         && candidate.getMethodName().equals("invoke");
   }
}

4. Flatten reflections invoke into a single line

public class ReflectionInvokeStackFrameFilter implements 
ExceptionStackFrameFilter<Throwable>
{
   @Override
   public StackFrameFilterResult process(StackFrame frame)
   {
      if (frame.isMarkSet("reflections.invoke"))
      {
         if (frame.getStackTraceElement().getMethodName().startsWith("invoke") 
||
            
frame.getStackTraceElement().getClassName().contains("_WeldClientProxy"))
         {
            return StackFrameFilterResult.DROP;
         }
         else
         {
            frame.clearMark("reflections.invoke");
         }
      }
      return StackFrameFilterResult.INCLUDE;
   }
}

> Include the ability to filter stack traces
> ------------------------------------------
>
>                 Key: SEAMCATCH-4
>                 URL: https://issues.jboss.org/browse/SEAMCATCH-4
>             Project: Seam Catch
>          Issue Type: Feature Request
>            Reporter: Jason Porter
>            Assignee: Jason Porter
>             Fix For: Alpha3
>
>
> Catch should support ideas such as 
> http://stackoverflow.com/questions/2504647/bash-how-to-filter-java-exception-info
>  http://squirrelsewer.blogspot.com/2010/03/filter-your-stack-traces.html and 
> http://pastebin.com/p8aCSeuu

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues

Reply via email to