~ubuntu-branches/debian/wheezy/jing-trang/wheezy

« back to all changes in this revision

Viewing changes to mod/rng-parse/src/main/com/thaiopensource/relaxng/parse/BuildException.java

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Thibault
  • Date: 2009-09-01 15:53:03 UTC
  • Revision ID: james.westby@ubuntu.com-20090901155303-2kweef05h5v9j3ni
Tags: upstream-20090818
ImportĀ upstreamĀ versionĀ 20090818

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}