View Javadoc
1   package de.japrost.jabudget.domain;
2   
3   /**
4    * Thrown on exceptions handling the domain.
5    */
6   // TODO generate messages 
7   public class DomainException extends Exception {
8   
9   	private static final long serialVersionUID = 1L;
10  	private final DomainFailure failure;
11  
12  	/**
13  	 * Create an instance based on a {@link Throwable}.
14  	 * 
15  	 * @param failure the failure code
16  	 * @param cause the cause of the failure
17  	 */
18  	public DomainException(DomainFailure failure, Throwable cause) {
19  		super(failure.toString(), cause);
20  		this.failure = failure;
21  	}
22  
23  	/**
24  	 * Create an instance.
25  	 * 
26  	 * @param failure the failure code
27  	 */
28  	public DomainException(DomainFailure failure) {
29  		super(failure.toString());
30  		this.failure = failure;
31  	}
32  
33  	/**
34  	 * Get the failure code.
35  	 * 
36  	 * @return the code
37  	 */
38  	public DomainFailure getFailure() {
39  		return failure;
40  	}
41  
42  }