ReactOS  0.4.13-dev-259-g5ca9c9c
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 
26 VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
27 {
29  TCHAR szMessage[1024];
30  LPTSTR szError;
31  va_list arg_ptr;
32 
33  if (dwErrorCode == ERROR_SUCCESS)
34  return;
35 
36  nErrorLevel = 1;
37 
38  if (szFormat)
39  {
40  va_start(arg_ptr, szFormat);
41  _vstprintf(szMessage, szFormat, arg_ptr);
42  va_end(arg_ptr);
43  }
44 
47  (LPTSTR)&szError, 0, NULL))
48  {
49  ConErrPrintf(_T("%s %s\n"), szError, szMessage);
50  if (szError)
51  LocalFree (szError);
52  return;
53  }
54 
55  /* Fall back just in case the error is not defined */
57  if (szFormat)
58  ConErrPrintf(_T("%s -- %s\n"), szMsg, szMessage);
59  else
60  ConErrPrintf(_T("%s\n"), szMsg);
61 }
62 
64 {
66  nErrorLevel = 1;
67 }
68 
69 
71 {
73  nErrorLevel = 1;
74 }
75 
76 
78 {
80  nErrorLevel = 1;
81 }
82 
83 
85 {
87  nErrorLevel = 1;
88 }
89 
90 
92 {
94  nErrorLevel = 1;
95 }
96 
97 
99 {
100  TCHAR szMsg[RC_STRING_MAX_SIZE];
101 
103  ConErrPrintf(_T("%s - %s\n"), szMsg, f);
104  nErrorLevel = 1;
105 }
106 
107 
109 {
111  nErrorLevel = 1;
112 }
113 
114 
116 {
118  nErrorLevel = 1;
119 }
120 
121 
123 {
125  nErrorLevel = 9009;
126 }
127 
128 
130 {
132  nErrorLevel = 1;
133 }
134 
135 
137 {
139  nErrorLevel = 1;
140 }
141 
142 
144 {
146  nErrorLevel = 1;
147 }
148 
149 
151 {
152  TCHAR szMsg[RC_STRING_MAX_SIZE];
153 
155 
156  if (s)
157  ConErrPrintf(_T("%s - %s\n"), szMsg, s);
158  else
159  ConErrPrintf(_T("%s.\n"), szMsg);
160 
161  nErrorLevel = 1;
162 }
163 
164 
166 {
168 }
169 
170 /* EOF */
INT nErrorLevel
Definition: cmd.c:157
#define STRING_ERROR_CANNOTPIPE
Definition: resource.h:15
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID error_out_of_memory(VOID)
Definition: error.c:136
VOID error_invalid_drive(VOID)
Definition: error.c:115
#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:63
#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:108
CHAR * LPTSTR
Definition: xmlstorage.h:192
VOID error_too_many_parameters(LPTSTR s)
Definition: error.c:77
#define STRING_ERROR_ERROR2
Definition: resource.h:44
#define va_end(ap)
Definition: acmsvcex.h:90
#define ConErrResPrintf(uID,...)
Definition: console.h:51
#define STRING_CONSOLE_ERROR
Definition: resource.h:34
VOID msg_pause(VOID)
Definition: error.c:165
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
VOID error_file_not_found(VOID)
Definition: error.c:91
char * va_list
Definition: acmsvcex.h:78
VOID error_bad_command(LPTSTR s)
Definition: error.c:122
#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
VOID ErrorMessage(DWORD dwErrorCode, LPTSTR szFormat,...)
Definition: error.c:26
char TCHAR
Definition: xmlstorage.h:189
GLfloat f
Definition: glext.h:7540
#define _T(x)
Definition: vfdio.h:22
#define STRING_ERROR_INVALID_DRIVE
Definition: resource.h:11
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
#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 STRING_ERROR_INVALID_PARAM_FORMAT
Definition: resource.h:5
#define FormatMessage
Definition: winbase.h:3609
VOID error_invalid_switch(TCHAR ch)
Definition: error.c:70
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:98
HANDLE CMD_ModuleHandle
Definition: cmd.c:164
VOID error_path_not_found(VOID)
Definition: error.c:84
#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:129
#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:143
#define LoadString
Definition: winuser.h:5685
VOID error_syntax(LPTSTR s)
Definition: error.c:150