001package org.jsoup.helper; 002 003import java.util.ArrayList; 004import java.util.List; 005 006/** 007 Validation exceptions, as thrown by the methods in {@link Validate}. 008 */ 009public class ValidationException extends IllegalArgumentException { 010 011 public static final String Validator = Validate.class.getName(); 012 013 public ValidationException(String msg) { 014 super(msg); 015 } 016 017 @Override 018 public synchronized Throwable fillInStackTrace() { 019 // Filters out the Validate class from the stacktrace, to more clearly point at the root-cause. 020 021 super.fillInStackTrace(); 022 023 StackTraceElement[] stackTrace = getStackTrace(); 024 List<StackTraceElement> filteredTrace = new ArrayList<>(); 025 for (StackTraceElement trace : stackTrace) { 026 if (trace.getClassName().equals(Validator)) continue; 027 filteredTrace.add(trace); 028 } 029 030 setStackTrace(filteredTrace.toArray(new StackTraceElement[0])); 031 032 return this; 033 } 034}