7fd59977 |
1 | |
2 | --Copyright: Matra Datavision 1992,1993 |
3 | |
4 | -- File: OSD_Error.cdl |
5 | -- Created: May 18 1992 |
6 | -- Author: Stephan GARNAUD (ARM) |
7 | -- <sga@sparc4> |
8 | |
9 | |
10 | class Error from OSD |
11 | |
12 | ---Purpose: Management of OSD errors |
13 | |
14 | -- Error handling style example: |
15 | -- |
16 | -- |
17 | -- try{ |
18 | -- . |
19 | -- . |
20 | -- . |
21 | -- OSD_Semaphore mysem("KeyName"); |
22 | -- if (mysem.Failed()) |
23 | -- switch (mysem.Error()){ |
24 | -- case 201: mysem.Perror(); |
25 | -- case 202: cout << "Just a warning"; |
26 | -- } |
27 | -- . |
28 | -- . |
29 | -- . |
30 | -- } |
31 | -- catch(Standard_Failure){ |
32 | -- Handle(Standard_Failure) Occur = Standard_Failure::Caught(); |
33 | -- . |
34 | -- . // Programmer's decision |
35 | -- . |
36 | -- |
37 | -- Each method can be error tested with object.Failed(). |
38 | -- To manage an occuring error, just use object.Perror(); |
39 | -- |
40 | -- It is possible to reset the error counter to zero. |
41 | -- To do this use the 'Reset' method . |
42 | |
43 | |
44 | -- Only 4 methods are usable for programmer : |
45 | -- Failed to see whether an error occured or not. |
46 | -- Value to get system independent error code. |
47 | -- (See annexe for a complete list of error code). |
48 | -- Reset to reset error code to zero (no error). |
49 | -- Perror to raise OSDError and print a self explanatory error |
50 | -- message. This message says why an error occurs and |
51 | -- explains what to do to correct it. |
52 | |
53 | uses |
54 | WhoAmI, AsciiString from TCollection |
55 | |
56 | raises |
57 | OSDError |
58 | |
59 | is |
60 | Create returns Error; |
61 | ---Purpose: Initializes Error to be without any Error. |
62 | -- This is only used by OSD, not by programmer. |
63 | ---Level: Public |
64 | |
65 | Perror (me : in out) |
66 | ---Purpose: Raises OSD_Error with accurate error message. |
67 | raises OSDError is static; |
68 | ---Level: Public |
69 | |
70 | SetValue (me : in out; Errcode : Integer; From : Integer; Message : AsciiString) is static; |
71 | ---Purpose: Instantiates error |
72 | -- This is only used by OSD methods to instantiates an error code. |
73 | -- No description is done for the programmer. |
74 | ---Level: Public |
75 | |
76 | Error (me) returns Integer is static; |
77 | ---Purpose: Returns an accurate error code. |
78 | -- To test these values, you must include "OSD_ErrorList.hxx" |
79 | ---Level: Public |
80 | |
81 | |
82 | Failed (me) returns Boolean is static; |
83 | ---Purpose: Returns TRUE if an error occurs |
84 | -- This is a way to test if a system call succeeded or not. |
85 | ---Level: Public |
86 | |
87 | Reset (me : in out) is static; |
88 | ---Purpose: Resets error counter to zero |
89 | -- This allows the user to ignore an error (WARNING). |
90 | ---Level: Public |
91 | |
92 | fields |
93 | myMessage : AsciiString; -- Internal error message |
94 | myErrno : Integer; -- UNIX/VMS error used by OSD only |
95 | myCode : WhoAmI; -- Accuracy code in error for OSD only |
96 | extCode : Integer; -- Error type decoded for user |
97 | end Error from OSD; |
98 | |
99 | |
100 | |
101 | |