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
9Module Name:
10
11 error.c
12
13Abstract:
14
15 Implementation of Error management functions.
16
17Revision History:
18
19
20
21--*/
22
23#include "pal/thread.hpp"
24#include "pal/dbgmsg.h"
25
26using namespace CorUnix;
27
28SET_DEFAULT_DEBUG_CHANNEL(MISC);
29
30/*++
31Function:
32 SetErrorMode
33
34The SetErrorMode function controls whether the system will handle the
35specified types of serious errors, or whether the process will handle
36them.
37
38Parameters
39
40uMode
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
50Return Values
51
52The return value is the previous state of the error-mode bit flags.
53
54--*/
55UINT
56PALAPI
57SetErrorMode(
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/*++
70Function:
71 GetLastError
72
73GetLastError
74
75The GetLastError function retrieves the calling thread's last-error
76code value. The last-error code is maintained on a per-thread
77basis. Multiple threads do not overwrite each other's last-error code.
78
79Parameters
80
81This function has no parameters.
82
83Return Values
84
85The return value is the calling thread's last-error code
86value. Functions set this value by calling the SetLastError
87function. The Return Value section of each reference page notes the
88conditions under which the function sets the last-error code.
89
90--*/
91DWORD
92PALAPI
93GetLastError(
94 VOID)
95{
96 return CPalThread::GetLastError();
97}
98
99
100
101/*++
102Function:
103 SetLastError
104
105SetLastError
106
107The SetLastError function sets the last-error code for the calling thread.
108
109Parameters
110
111dwErrCode
112 [in] Specifies the last-error code for the thread.
113
114Return Values
115
116This function does not return a value.
117
118--*/
119VOID
120PALAPI
121SetLastError(
122 IN DWORD dwErrCode)
123{
124 CPalThread::SetLastError(dwErrCode);
125}
126
127