1   package com.trendmicro.grid.acl.l0;
2   
3   import org.slf4j.Logger;
4   import org.slf4j.LoggerFactory;
5   
6   import javax.xml.bind.annotation.*;
7   import javax.xml.ws.WebFault;
8   
9   /**
10   * Defines a generic fault for webservice related issues.
11   *
12   * @author Juergen_Kellerer, 2010-04-26
13   * @version 1.0
14   */
15  @XmlAccessorType(XmlAccessType.FIELD)
16  @XmlType(namespace = Level0Constants.NAMESPACE)
17  @WebFault(targetNamespace = Level0Constants.NAMESPACE)
18  public class WebException extends Exception {
19  
20  	private static final Logger log = LoggerFactory.getLogger(WebException.class);
21  	private static final long serialVersionUID = -5854824433574110209L;
22  
23  	@XmlAttribute
24  	private String code;
25  
26  	@XmlElement
27  	private String message;
28  
29  	public WebException() {
30  	}
31  
32  	public WebException(String message) {
33  		super(message);
34  		this.message = message;
35  	}
36  
37  	public WebException(String code, String message) {
38  		super(message);
39  		this.code = code;
40  		this.message = message;
41  
42  		if (log.isTraceEnabled()) {
43  			log.trace("About to throw {} (WebException), Code: {}, Message: {}",
44  					new Object[]{getClass().getSimpleName(), code, message});
45  		}
46  	}
47  
48  	public String getCode() {
49  		return code;
50  	}
51  
52  	@Override
53  	public Throwable initCause(Throwable cause) {
54  		if (log.isTraceEnabled()) {
55  			log.trace("About to set the cause for throwing " +
56  					getClass().getSimpleName() + " (WebException) to: ", cause);
57  		}
58  		return super.initCause(cause);
59  	}
60  }