1 | package desmoj.core.report; |
2 | |
3 | import desmoj.core.simulator.Model; |
4 | import desmoj.core.simulator.TimeInstant; |
5 | |
6 | /** |
7 | * An ErrorMessage is used to signal invalid situations to the modeller. An |
8 | * ErrorMessage consists of four Strings that intend to define the kind of error |
9 | * that occurred and describe its reason and what a modeller can do to prevent |
10 | * it. ErrorMessages describe types of errors that can be fixed by the DESMO-J |
11 | * or just give hints on missing or unclear parameters where certain framework |
12 | * assumptions are made. ErrorMessages report these to the modeller. Any type of |
13 | * error consists of the following attributes which have to be set by the |
14 | * ErrorMessage's constructor: |
15 | * <ul> |
16 | * <li>error description : The operation that just failed or does not have the |
17 | * preconditions matched</li> |
18 | * <li>error location : The class and method that the error occurred in</li> |
19 | * <li>error reason : The probable reason why the error occured</li> |
20 | * <li>error prevention : A hint on how to prevent this error to occur again. |
21 | * </li> |
22 | * <li>error time : The point of simulation time that the error occurred.</li> |
23 | * </ul> |
24 | * Note that ErrorMessages relate to the modeller's use of the framework's |
25 | * methods and correct the found problems if possible by making assumptions. |
26 | * These corrections and their assumptions are articulated by an ErrorMessage. |
27 | * In contrast to <code>Exceptions</code> and fatal errors, an ErrorMessage |
28 | * does not stop the simulation run or exit the Java runtime. |
29 | * |
30 | * @version DESMO-J, Ver. 2.3.3 copyright (c) 2011 |
31 | * @author Tim Lechler |
32 | * |
33 | * Licensed under the Apache License, Version 2.0 (the "License"); |
34 | * you may not use this file except in compliance with the License. You |
35 | * may obtain a copy of the License at |
36 | * http://www.apache.org/licenses/LICENSE-2.0 |
37 | * |
38 | * Unless required by applicable law or agreed to in writing, software |
39 | * distributed under the License is distributed on an "AS IS" |
40 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
41 | * or implied. See the License for the specific language governing |
42 | * permissions and limitations under the License. |
43 | * |
44 | */ |
45 | public class ErrorMessage extends Message { |
46 | |
47 | /* |
48 | * The reason that caused the operation to fail. It is a description of the |
49 | * circumstances leading to the warning. Use not more than one short |
50 | * sentence. |
51 | */ |
52 | private String _errReason; |
53 | |
54 | /* |
55 | * Describes in a few sentences how the warning can be prevented in the |
56 | * future. |
57 | */ |
58 | private String _errPrevention; |
59 | |
60 | /** |
61 | * The location that this message was created as a String consisting of |
62 | * "Classname.Methodname". |
63 | */ |
64 | private String _errLocation; |
65 | |
66 | /** |
67 | * Creates an errormessage setting its parameters with the given values. |
68 | * |
69 | * @param origin |
70 | * Model : The model this errormessage evolved from |
71 | * @param errorDescription |
72 | * java.lang.String : Description of the error |
73 | * @param errorLocation |
74 | * java.lang.String : Class and method the error occured in |
75 | * @param errorReason |
76 | * java.lang.String : The probable reason for the error |
77 | * @param errorPrevention |
78 | * java.lang.String : A hint how to prevent the error |
79 | */ |
80 | //TODO: |
81 | public ErrorMessage(Model origin, String errorDescription, |
82 | String errorLocation, String errorReason, String errorPrevention, |
83 | TimeInstant errorTime) { |
84 | |
85 | // create the Message |
86 | super(origin, errorDescription, errorTime); |
87 | |
88 | // set the new attributes |
89 | _errLocation = errorLocation; |
90 | _errReason = errorReason; |
91 | _errPrevention = errorPrevention; |
92 | |
93 | } |
94 | |
95 | /** |
96 | * Returns a String describing class and method that this message was sent |
97 | * from. |
98 | * |
99 | * @return java.lang.String : The location this message was sent from. |
100 | */ |
101 | public String getLocation() { |
102 | |
103 | return _errLocation; |
104 | |
105 | } |
106 | |
107 | /** |
108 | * Returns a String giving a hint on how to prevent this error to happen. |
109 | * Note that the hint given is based on the probable reason described but |
110 | * must not always have that reason. |
111 | * |
112 | * @return java.lang.String : The probable reason for this error |
113 | */ |
114 | public String getPrevention() { |
115 | |
116 | return _errPrevention; |
117 | |
118 | } |
119 | |
120 | /** |
121 | * Returns the String describing the probable reason for the error to occur. |
122 | * Note that the reason given here is the most probable reason for the |
123 | * effect to occur here. It might have its origin in other classes, so bear |
124 | * in mind that the casue for the error might have been created in a class |
125 | * not obviously related to the location this error occured. |
126 | * |
127 | * @return java.lang.String : The probable reason for this error |
128 | */ |
129 | public String getReason() { |
130 | |
131 | return _errReason; |
132 | |
133 | } |
134 | } |