ReactOS  0.4.15-dev-341-g17c5fb8
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 
25 VOID
27  IN DWORD dwErrorCode,
28  IN LPTSTR szFormat OPTIONAL,
29  ...)
30 {
31  va_list arg_ptr;
32  LPTSTR szError;
34  TCHAR szMessage[1024];
35 
36  if (dwErrorCode == ERROR_SUCCESS)
37  return;
38 
39  nErrorLevel = 1;
40 
41  *szMessage = 0;
42  if (szFormat)
43  {
44  va_start(arg_ptr, szFormat);
45  _vstprintf(szMessage, szFormat, arg_ptr);
46  va_end(arg_ptr);
47  }
48 
51  (LPTSTR)&szError, 0, NULL))
52  {
53  ConErrPrintf(_T("%s %s\n"), szError, szMessage);
54  if (szError)
55  LocalFree(szError);
56  return;
57  }
58 
59  /* Fall back just in case the error is not defined */
61  if (szFormat)
62  ConErrPrintf(_T("%s -- %s\n"), szMsg, szMessage);
63  else
64  ConErrPrintf(_T("%s\n"), szMsg);
65 }
66 
68 {
70  nErrorLevel = 1;
71 }
72 
73 
75 {
77  nErrorLevel = 1;
78 }
79 
80 
82 {
84  nErrorLevel = 1;
85 }
86 
87 
89 {
91  nErrorLevel = 1;
92 }
93 
94 
96 {
98  nErrorLevel = 1;
99 }
100 
101 
103 {
104  TCHAR szMsg[RC_STRING_MAX_SIZE];
105 
107  ConErrPrintf(_T("%s - %s\n"), szMsg, f);
108  nErrorLevel = 1;
109 }
110 
111 
113 {
115  nErrorLevel = 1;
116 }
117 
118 
120 {
122  nErrorLevel = 1;
123 }
124 
125 
127 {
129  nErrorLevel = 9009;
130 }
131 
132 
134 {
136  nErrorLevel = 1;
137 }
138 
139 
141 {
143  nErrorLevel = 1;
144 }
145 
146 
148 {
150  nErrorLevel = 1;
151 }
152 
153 
155 {
156  TCHAR szMsg[RC_STRING_MAX_SIZE];
157 
159 
160  if (s)
161  ConErrPrintf(_T("%s - %s\n"), szMsg, s);
162  else
163  ConErrPrintf(_T("%s.\n"), szMsg);
164 
165  nErrorLevel = 1;
166 }
167 
168 
170 {
172 }
173 
174 /* EOF */
INT nErrorLevel
Definition: cmd.c:157
#define STRING_ERROR_CANNOTPIPE
Definition: resource.h:15
#define IN
Definition: typedefs.h:39
#define ERROR_SUCCESS
Definition: deptool.c:10
#define STRING_CONSOLE_ERROR
Definition: resource.h:6
VOID error_out_of_memory(VOID)
Definition: error.c:140
VOID error_invalid_drive(VOID)
Definition: error.c:119
#define LANG_NEUTRAL
Definition: nls.h:22
#define ConErrResPuts(uID)
Definition: console.h:39
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define _vstprintf
Definition: tchar.h:540
VOID error_parameter_format(TCHAR ch)
Definition: error.c:67
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define STRING_ERROR_REQ_PARAM_MISSING
Definition: resource.h:10
VOID error_req_param_missing(VOID)
Definition: error.c:112
#define STRING_ERROR_INVALID_DRIVE
Definition: resource.h:13
CHAR * LPTSTR
Definition: xmlstorage.h:192
VOID error_too_many_parameters(LPTSTR s)
Definition: error.c:81
#define STRING_ERROR_ERROR2
Definition: resource.h:44
VOID ErrorMessage(IN DWORD dwErrorCode, IN LPTSTR szFormat OPTIONAL,...)
Definition: error.c:26
#define va_end(ap)
Definition: acmsvcex.h:90
#define ConErrResPrintf(uID,...)
Definition: console.h:51
VOID msg_pause(VOID)
Definition: error.c:169
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
#define STRING_ERROR_INVALID_PARAM_FORMAT
Definition: resource.h:5
smooth NULL
Definition: ftsmooth.c:416
VOID error_file_not_found(VOID)
Definition: error.c:95
char * va_list
Definition: acmsvcex.h:78
VOID error_bad_command(LPTSTR s)
Definition: error.c:126
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
VOID ConErrPrintf(LPTSTR szFormat,...)
Definition: tee.c:36
#define STRING_ERROR_OUT_OF_MEMORY
Definition: resource.h:14
char TCHAR
Definition: xmlstorage.h:189
GLfloat f
Definition: glext.h:7540
#define _T(x)
Definition: vfdio.h:22
#define STRING_ERROR_BADCOMMAND
Definition: resource.h:13
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STRING_ERROR_D_PAUSEMSG
Definition: resource.h:16
#define FormatMessage
Definition: winbase.h:3635
VOID error_invalid_switch(TCHAR ch)
Definition: error.c:74
GLdouble s
Definition: gl.h:2039
#define STRING_ERROR_PATH_NOT_FOUND
Definition: resource.h:8
#define STRING_ERROR_INVALID_SWITCH
Definition: resource.h:6
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define va_start(ap, A)
Definition: acmsvcex.h:91
VOID error_sfile_not_found(LPTSTR f)
Definition: error.c:102
HANDLE CMD_ModuleHandle
Definition: cmd.c:164
VOID error_path_not_found(VOID)
Definition: error.c:88
#define STRING_ERROR_TOO_MANY_PARAMETERS
Definition: resource.h:7
#define STRING_ERROR_FILE_NOT_FOUND
Definition: resource.h:9
#define ConOutResPuts(uID)
Definition: console.h:36
VOID error_no_pipe(VOID)
Definition: error.c:133
#define MAKELANGID(p, s)
Definition: nls.h:15
#define STRING_ERROR_PARAMETERF_ERROR
Definition: resource.h:5
VOID error_invalid_parameter_format(LPTSTR s)
Definition: error.c:147
#define LoadString
Definition: winuser.h:5794
VOID error_syntax(LPTSTR s)
Definition: error.c:154
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68