1 16 package org.apache.cocoon; 17 18 import java.util.List ; 19 20 import org.apache.cocoon.util.location.LocatedException; 21 import org.apache.cocoon.util.location.LocatedRuntimeException; 22 import org.apache.cocoon.util.location.Location; 23 import org.apache.cocoon.util.location.MultiLocatable; 24 25 33 public class ProcessingException extends LocatedException implements MultiLocatable { 34 35 38 public ProcessingException(String message) { 39 super(message); 40 } 41 42 47 public ProcessingException(Exception ex) { 48 super(ex.getMessage(), ex); 49 } 50 51 55 public ProcessingException(String message, Throwable t) { 56 super(message, t); 57 } 58 59 62 public ProcessingException(String message, Location location) { 63 super(message, location); 64 } 65 66 73 protected ProcessingException(String message, Throwable t, Location location) { 74 super(message, t, location); 75 } 76 77 99 public static ProcessingException throwLocated(String message, Throwable thr, Location location) throws ProcessingException { 100 if (thr instanceof ProcessingException) { 101 ProcessingException pe = (ProcessingException)thr; 102 pe.addLocation(location); 103 throw pe; 104 105 } else if (thr instanceof LocatedRuntimeException) { 106 LocatedRuntimeException re = (LocatedRuntimeException)thr; 107 re.addLocation(location); 108 throw re; 110 } 111 112 throw new ProcessingException(message, thr, location); 113 } 114 115 137 public static ProcessingException throwLocated(String message, Throwable thr, List locations) throws ProcessingException { 138 MultiLocatable multiloc; 139 if (thr instanceof ProcessingException) { 140 multiloc = (ProcessingException)thr; 141 } else if (thr instanceof LocatedRuntimeException) { 142 multiloc = (LocatedRuntimeException)thr; 143 } else { 144 multiloc = new ProcessingException(message, thr); 145 } 146 147 if (locations != null) { 148 for (int i = 0; i < locations.size(); i++) { 149 multiloc.addLocation((Location)locations.get(i)); 150 } 151 } 152 153 if (multiloc instanceof LocatedRuntimeException) { 154 throw (LocatedRuntimeException)multiloc; 155 } else { 156 throw (ProcessingException)multiloc; 157 } 158 } 159 } 160 | Popular Tags |