1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*++ |
6 | |
7 | |
8 | |
9 | Module Name: |
10 | |
11 | error.c |
12 | |
13 | Abstract: |
14 | |
15 | Implementation of Error management functions. |
16 | |
17 | Revision History: |
18 | |
19 | |
20 | |
21 | --*/ |
22 | |
23 | #include "pal/thread.hpp" |
24 | #include "pal/dbgmsg.h" |
25 | |
26 | using namespace CorUnix; |
27 | |
28 | SET_DEFAULT_DEBUG_CHANNEL(MISC); |
29 | |
30 | /*++ |
31 | Function: |
32 | SetErrorMode |
33 | |
34 | The SetErrorMode function controls whether the system will handle the |
35 | specified types of serious errors, or whether the process will handle |
36 | them. |
37 | |
38 | Parameters |
39 | |
40 | uMode |
41 | [in] Specifies the process error mode. This parameter can be one or more of the following values. |
42 | |
43 | Value Action |
44 | 0 Use the system default, which is to display all error dialog boxes. |
45 | SEM_FAILCRITICALERRORS The system does not display the critical-error-handler message box. Instead, |
46 | the system sends the error to the calling process. |
47 | SEM_NOOPENFILEERRORBOX The system does not display a message box when it fails to find a file. Instead, |
48 | the error is returned to the calling process. |
49 | |
50 | Return Values |
51 | |
52 | The return value is the previous state of the error-mode bit flags. |
53 | |
54 | --*/ |
55 | UINT |
56 | PALAPI |
57 | SetErrorMode( |
58 | IN UINT uMode) |
59 | { |
60 | PERF_ENTRY(SetErrorMode); |
61 | ENTRY("SetErrorMode (uMode=%#x)\n" , uMode); |
62 | |
63 | LOGEXIT("SetErrorMode returns UINT 0\n" ); |
64 | PERF_EXIT(SetErrorMode); |
65 | return 0; |
66 | } |
67 | |
68 | |
69 | /*++ |
70 | Function: |
71 | GetLastError |
72 | |
73 | GetLastError |
74 | |
75 | The GetLastError function retrieves the calling thread's last-error |
76 | code value. The last-error code is maintained on a per-thread |
77 | basis. Multiple threads do not overwrite each other's last-error code. |
78 | |
79 | Parameters |
80 | |
81 | This function has no parameters. |
82 | |
83 | Return Values |
84 | |
85 | The return value is the calling thread's last-error code |
86 | value. Functions set this value by calling the SetLastError |
87 | function. The Return Value section of each reference page notes the |
88 | conditions under which the function sets the last-error code. |
89 | |
90 | --*/ |
91 | DWORD |
92 | PALAPI |
93 | GetLastError( |
94 | VOID) |
95 | { |
96 | return CPalThread::GetLastError(); |
97 | } |
98 | |
99 | |
100 | |
101 | /*++ |
102 | Function: |
103 | SetLastError |
104 | |
105 | SetLastError |
106 | |
107 | The SetLastError function sets the last-error code for the calling thread. |
108 | |
109 | Parameters |
110 | |
111 | dwErrCode |
112 | [in] Specifies the last-error code for the thread. |
113 | |
114 | Return Values |
115 | |
116 | This function does not return a value. |
117 | |
118 | --*/ |
119 | VOID |
120 | PALAPI |
121 | SetLastError( |
122 | IN DWORD dwErrCode) |
123 | { |
124 | CPalThread::SetLastError(dwErrCode); |
125 | } |
126 | |
127 | |