| 1 |
package com.thaiopensource.relaxng.parse; |
| 2 |
|
| 3 |
import com.thaiopensource.resolver.ResolverException; |
| 4 |
import org.xml.sax.SAXException; |
| 5 |
|
| 6 |
public class BuildException extends RuntimeException { |
| 7 |
private final Throwable cause; |
| 8 |
public BuildException(Throwable cause) { |
| 9 |
if (cause == null) |
| 10 |
throw new NullPointerException("null cause"); |
| 11 |
this.cause = cause; |
| 12 |
} |
| 13 |
|
| 14 |
public Throwable getCause() { |
| 15 |
return cause; |
| 16 |
} |
| 17 |
|
| 18 |
public static BuildException fromSAXException(SAXException e) { |
| 19 |
Exception inner = e.getException(); |
| 20 |
if (inner instanceof BuildException) |
| 21 |
return (BuildException)inner; |
| 22 |
return new BuildException(e); |
| 23 |
} |
| 24 |
|
| 25 |
public static BuildException fromResolverException(ResolverException e) { |
| 26 |
if (e.getMessage() == null) { |
| 27 |
Throwable t = e.unwrap(); |
| 28 |
if (t != null) { |
| 29 |
if (t instanceof BuildException) |
| 30 |
throw (BuildException)t; |
| 31 |
throw new BuildException(t); |
| 32 |
} |
| 33 |
} |
| 34 |
throw new BuildException(e); |
| 35 |
} |
| 36 |
} |