ReactOS 0.4.16-dev-88-ga65b6ae
error.c
Go to the documentation of this file.
1/*
2 * ERROR.C - error reporting functions.
3 *
4 *
5 * History:
6 *
7 * 07/12/98 (Rob Lake)
8 * started
9 *
10 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
11 * added config.h include
12 *
13 * 24-Jan-1999 (Eric Kohl)
14 * Redirection safe!
15 *
16 * 02-Feb-1999 (Eric Kohl)
17 * Use FormatMessage() for error reports.
18 *
19 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
20 * Remove all hardcoded strings in En.rc
21 */
22
23#include "precomp.h"
24
25VOID
27 IN DWORD dwErrorCode,
28 IN PCWSTR szFormat OPTIONAL,
29 ...)
30{
31 va_list arg_ptr;
32 PWSTR szError;
34 TCHAR szMessage[1024];
35
36 if (dwErrorCode == ERROR_SUCCESS)
37 return;
38
39 *szMessage = 0;
40 if (szFormat)
41 {
42 va_start(arg_ptr, szFormat);
43 vswprintf(szMessage, szFormat, arg_ptr);
44 va_end(arg_ptr);
45 }
46
49 (PTSTR)&szError, 0, NULL))
50 {
51 ConErrPrintf(_T("%s%s%s"), szError, szMessage, (*szMessage ? _T("\n") : _T("")));
52 if (szError)
53 LocalFree(szError);
54 return;
55 }
56
57 /* Fall back just in case the error is not defined */
59 if (szFormat)
60 ConErrPrintf(_T("%s -- %s\n"), szMsg, szMessage);
61 else
62 ConErrPrintf(_T("%s\n"), szMsg);
63}
64
66{
68 nErrorLevel = 1;
69}
70
71
73{
75 nErrorLevel = 1;
76}
77
78
80{
82 nErrorLevel = 1;
83}
84
85
87{
89 nErrorLevel = 1;
90}
91
92
94{
96 nErrorLevel = 1;
97}
98
99
101{
103
105 ConErrPrintf(_T("%s - %s\n"), szMsg, s);
106 nErrorLevel = 1;
107}
108
109
111{
113 nErrorLevel = 1;
114}
115
116
118{
120 nErrorLevel = 1;
121}
122
123
125{
127 nErrorLevel = 9009;
128}
129
130
132{
134 nErrorLevel = 1;
135}
136
137
139{
141 nErrorLevel = 1;
142}
143
144
146{
148 nErrorLevel = 1;
149}
150
151
153{
155
157
158 if (s)
159 ConErrPrintf(_T("%s - %s\n"), szMsg, s);
160 else
161 ConErrPrintf(_T("%s.\n"), szMsg);
162
163 nErrorLevel = 1;
164}
165
166
168{
170}
171
172/* EOF */
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
#define STRING_ERROR_INVALID_PARAM_FORMAT
Definition: resource.h:5
#define STRING_CONSOLE_ERROR
Definition: resource.h:6
#define STRING_ERROR_INVALID_DRIVE
Definition: resource.h:13
#define STRING_ERROR_OUT_OF_MEMORY
Definition: resource.h:26
#define STRING_ERROR_D_PAUSEMSG
Definition: resource.h:27
INT nErrorLevel
Definition: cmd.c:158
HANDLE CMD_ModuleHandle
Definition: cmd.c:165
#define ConErrPrintf(szStr,...)
Definition: console.h:44
#define ConErrResPuts(uID)
Definition: console.h:38
#define ConErrResPrintf(uID,...)
Definition: console.h:50
VOID ErrorMessage(IN DWORD dwErrorCode, IN PCWSTR szFormat OPTIONAL,...)
Definition: error.c:26
VOID error_invalid_drive(VOID)
Definition: error.c:117
VOID error_bad_command(PCWSTR s)
Definition: error.c:124
VOID msg_pause(VOID)
Definition: error.c:167
VOID error_path_not_found(VOID)
Definition: error.c:86
VOID error_no_pipe(VOID)
Definition: error.c:131
VOID error_file_not_found(VOID)
Definition: error.c:93
VOID error_invalid_parameter_format(PCWSTR s)
Definition: error.c:145
VOID error_req_param_missing(VOID)
Definition: error.c:110
VOID error_out_of_memory(VOID)
Definition: error.c:138
VOID error_parameter_format(WCHAR ch)
Definition: error.c:65
VOID error_sfile_not_found(PCWSTR s)
Definition: error.c:100
VOID error_too_many_parameters(PCWSTR s)
Definition: error.c:79
VOID error_invalid_switch(WCHAR ch)
Definition: error.c:72
VOID error_syntax(PCWSTR s)
Definition: error.c:152
#define STRING_ERROR_CANNOTPIPE
Definition: resource.h:15
#define STRING_ERROR_BADCOMMAND
Definition: resource.h:13
#define STRING_ERROR_INVALID_SWITCH
Definition: resource.h:6
#define STRING_ERROR_ERROR2
Definition: resource.h:51
#define STRING_ERROR_FILE_NOT_FOUND
Definition: resource.h:9
#define STRING_ERROR_PATH_NOT_FOUND
Definition: resource.h:8
#define STRING_ERROR_TOO_MANY_PARAMETERS
Definition: resource.h:7
#define STRING_ERROR_PARAMETERF_ERROR
Definition: resource.h:5
#define STRING_ERROR_REQ_PARAM_MISSING
Definition: resource.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static _Check_return_opt_ int __cdecl vswprintf(_Out_writes_z_(_SizeInWords) wchar_t *_DstBuf, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
Definition: stdio.h:977
#define ConOutResPuts(uID)
Definition: replace.h:28
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
#define _T(x)
Definition: vfdio.h:22
#define FormatMessage
Definition: winbase.h:3795
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
#define LoadString
Definition: winuser.h:5831
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * PTSTR
Definition: xmlstorage.h:191