ReactOS  0.4.13-dev-479-gec9c8fd
error.c File Reference
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include "jscript.h"
#include "wine/debug.h"
Include dependency graph for error.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static HRESULT Error_toString (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Error_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT alloc_error (script_ctx_t *ctx, jsdisp_t *prototype, jsdisp_t *constr, jsdisp_t **ret)
 
static HRESULT create_error (script_ctx_t *ctx, jsdisp_t *constr, UINT number, jsstr_t *msg, jsdisp_t **ret)
 
static HRESULT error_constr (script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
 
static HRESULT ErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT EvalErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT RangeErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT ReferenceErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT RegExpErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT SyntaxErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT TypeErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT URIErrorConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT init_error_constr (script_ctx_t *ctx, jsdisp_t *object_prototype)
 
static HRESULT throw_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
 
HRESULT throw_generic_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 
HRESULT throw_range_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 
HRESULT throw_reference_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 
HRESULT throw_regexp_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 
HRESULT throw_syntax_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 
HRESULT throw_type_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 
HRESULT throw_uri_error (script_ctx_t *ctx, HRESULT error, const WCHAR *str)
 

Variables

static const WCHAR descriptionW [] = {'d','e','s','c','r','i','p','t','i','o','n',0}
 
static const WCHAR messageW [] = {'m','e','s','s','a','g','e',0}
 
static const WCHAR nameW [] = {'n','a','m','e',0}
 
static const WCHAR numberW [] = {'n','u','m','b','e','r',0}
 
static const WCHAR toStringW [] = {'t','o','S','t','r','i','n','g',0}
 
static const builtin_prop_t Error_props []
 
static const builtin_info_t Error_info
 
static const builtin_info_t ErrorInst_info
 

Function Documentation

◆ alloc_error()

static HRESULT alloc_error ( script_ctx_t ctx,
jsdisp_t prototype,
jsdisp_t constr,
jsdisp_t **  ret 
)
static

Definition at line 162 of file error.c.

164 {
165  jsdisp_t *err;
166  HRESULT hres;
167 
168  err = heap_alloc_zero(sizeof(*err));
169  if(!err)
170  return E_OUTOFMEMORY;
171 
172  if(prototype)
173  hres = init_dispex(err, ctx, &Error_info, prototype);
174  else
176  constr ? constr : ctx->error_constr);
177  if(FAILED(hres)) {
178  heap_free(err);
179  return hres;
180  }
181 
182  *ret = err;
183  return S_OK;
184 }
jsdisp_t * error_constr
Definition: jscript.h:441
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const builtin_info_t ErrorInst_info
Definition: error.c:153
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
static const builtin_info_t Error_info
Definition: error.c:144
#define err(...)
#define S_OK
Definition: intsafe.h:59
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:940
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1051
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_error(), and init_error_constr().

◆ create_error()

static HRESULT create_error ( script_ctx_t ctx,
jsdisp_t constr,
UINT  number,
jsstr_t msg,
jsdisp_t **  ret 
)
static

Definition at line 186 of file error.c.

188 {
189  jsdisp_t *err;
190  HRESULT hres;
191 
192  hres = alloc_error(ctx, NULL, constr, &err);
193  if(FAILED(hres))
194  return hres;
195 
198  if(FAILED(hres)) {
200  return hres;
201  }
202 
205  jsval_string(msg));
206  if(SUCCEEDED(hres))
208  jsval_string(msg));
209  if(FAILED(hres)) {
211  return hres;
212  }
213 
214  *ret = err;
215  return S_OK;
216 }
#define PROPF_WRITABLE
Definition: jscript.h:98
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1794
static const WCHAR messageW[]
Definition: error.c:31
#define PROPF_ENUMERABLE
Definition: jscript.h:97
int32_t INT
Definition: typedefs.h:56
static size_t double number
Definition: printf.c:64
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR numberW[]
Definition: error.c:33
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
#define err(...)
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static const WCHAR descriptionW[]
Definition: error.c:30
#define msg(x)
Definition: auth_time.c:54
#define PROPF_CONFIGURABLE
Definition: jscript.h:99
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT alloc_error(script_ctx_t *ctx, jsdisp_t *prototype, jsdisp_t *constr, jsdisp_t **ret)
Definition: error.c:162

Referenced by error_constr(), test_file_access(), and throw_error().

◆ error_constr()

static HRESULT error_constr ( script_ctx_t ctx,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r,
jsdisp_t constr 
)
static

Definition at line 218 of file error.c.

219  {
220  jsdisp_t *err;
221  UINT num = 0;
222  jsstr_t *msg = NULL;
223  HRESULT hres;
224 
225  if(argc) {
226  double n;
227 
228  hres = to_number(ctx, argv[0], &n);
229  if(FAILED(hres)) /* FIXME: really? */
230  n = NAN;
231  if(isnan(n))
232  hres = to_string(ctx, argv[0], &msg);
233  if(FAILED(hres))
234  return hres;
235  num = n;
236  }
237 
238  if(!msg) {
239  if(argc > 1) {
240  hres = to_string(ctx, argv[1], &msg);
241  if(FAILED(hres))
242  return hres;
243  }else {
244  msg = jsstr_empty();
245  }
246  }
247 
248  switch(flags) {
249  case INVOKE_FUNC:
250  case DISPATCH_CONSTRUCT:
251  hres = create_error(ctx, constr, num, msg, &err);
253  if(FAILED(hres))
254  return hres;
255 
256  if(r)
257  *r = jsval_obj(err);
258  else
260  return S_OK;
261 
262  default:
263  if(msg)
265  FIXME("unimplemented flags %x\n", flags);
266  return E_NOTIMPL;
267  }
268 }
static int argc
Definition: ServiceArgs.c:12
static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr, UINT number, jsstr_t *msg, jsdisp_t **ret)
Definition: error.c:186
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
#define FIXME(fmt,...)
Definition: debug.h:110
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLuint GLuint num
Definition: glext.h:9618
#define NAN
Definition: misc.c:46
GLbitfield flags
Definition: glext.h:7161
#define err(...)
int isnan(double x)
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
unsigned int UINT
Definition: ndis.h:50
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define msg(x)
Definition: auth_time.c:54

Referenced by ErrorConstr_value(), EvalErrorConstr_value(), RangeErrorConstr_value(), ReferenceErrorConstr_value(), RegExpErrorConstr_value(), SyntaxErrorConstr_value(), TypeErrorConstr_value(), and URIErrorConstr_value().

◆ Error_toString()

static HRESULT Error_toString ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 37 of file error.c.

39 {
40  jsdisp_t *jsthis;
41  jsstr_t *name = NULL, *msg = NULL, *ret = NULL;
42  jsval_t v;
43  HRESULT hres;
44 
45  static const WCHAR object_errorW[] = {'[','o','b','j','e','c','t',' ','E','r','r','o','r',']',0};
46 
47  TRACE("\n");
48 
49  jsthis = get_jsdisp(vthis);
50  if(!jsthis || ctx->version < 2) {
51  if(r) {
52  jsstr_t *str;
53 
54  str = jsstr_alloc(object_errorW);
55  if(!str)
56  return E_OUTOFMEMORY;
57  *r = jsval_string(str);
58  }
59  return S_OK;
60  }
61 
62  hres = jsdisp_propget_name(jsthis, nameW, &v);
63  if(FAILED(hres))
64  return hres;
65 
66  if(!is_undefined(v)) {
67  hres = to_string(ctx, v, &name);
69  if(FAILED(hres))
70  return hres;
71  }
72 
73  hres = jsdisp_propget_name(jsthis, messageW, &v);
74  if(SUCCEEDED(hres)) {
75  if(!is_undefined(v)) {
76  hres = to_string(ctx, v, &msg);
78  }
79  }
80 
81  if(SUCCEEDED(hres)) {
82  unsigned name_len = name ? jsstr_length(name) : 0;
83  unsigned msg_len = msg ? jsstr_length(msg) : 0;
84 
85  if(name_len && msg_len) {
86  WCHAR *ptr;
87 
88  ret = jsstr_alloc_buf(name_len + msg_len + 2, &ptr);
89  if(ret) {
91  ptr[name_len] = ':';
92  ptr[name_len+1] = ' ';
93  jsstr_flush(msg, ptr+name_len+2);
94  }else {
96  }
97  }else if(name_len) {
98  ret = name;
99  name = NULL;
100  }else if(msg_len) {
101  ret = msg;
102  msg = NULL;
103  }else {
104  ret = jsstr_alloc(object_errorW);
105  }
106  }
107 
108  if(msg)
110  if(name)
112  if(FAILED(hres))
113  return hres;
114  if(!ret)
115  return E_OUTOFMEMORY;
116 
117  if(r)
118  *r = jsval_string(ret);
119  else
121  return S_OK;
122 }
Definition: jsval.h:54
static const WCHAR nameW[]
Definition: error.c:32
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
void jsval_release(jsval_t val)
Definition: jsutils.c:189
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const WCHAR messageW[]
Definition: error.c:31
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
DWORD version
Definition: jscript.h:415
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
static jsdisp_t * get_jsdisp(vdisp_t *vdisp)
Definition: jscript.h:195
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1429
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
#define msg(x)
Definition: auth_time.c:54
Definition: name.c:36
#define SUCCEEDED(hr)
Definition: intsafe.h:57
GLuint const GLchar * name
Definition: glext.h:6031

◆ Error_value()

static HRESULT Error_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 124 of file error.c.

126 {
127  TRACE("\n");
128 
129  switch(flags) {
130  case INVOKE_FUNC:
132  default:
133  FIXME("unimplemented flags %x\n", flags);
134  return E_NOTIMPL;
135  }
136 
137  return S_OK;
138 }
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:553
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438

◆ ErrorConstr_value()

static HRESULT ErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 270 of file error.c.

272 {
273  TRACE("\n");
274  return error_constr(ctx, flags, argc, argv, r, ctx->error_constr);
275 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
jsdisp_t * error_constr
Definition: jscript.h:441
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218

Referenced by init_error_constr().

◆ EvalErrorConstr_value()

static HRESULT EvalErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 277 of file error.c.

279 {
280  TRACE("\n");
281  return error_constr(ctx, flags, argc, argv, r, ctx->eval_error_constr);
282 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218
jsdisp_t * eval_error_constr
Definition: jscript.h:442

Referenced by init_error_constr().

◆ init_error_constr()

HRESULT init_error_constr ( script_ctx_t ctx,
jsdisp_t object_prototype 
)

Definition at line 326 of file error.c.

327 {
328  static const WCHAR ErrorW[] = {'E','r','r','o','r',0};
329  static const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0};
330  static const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0};
331  static const WCHAR ReferenceErrorW[] = {'R','e','f','e','r','e','n','c','e','E','r','r','o','r',0};
332  static const WCHAR RegExpErrorW[] = {'R','e','g','E','x','p','E','r','r','o','r',0};
333  static const WCHAR SyntaxErrorW[] = {'S','y','n','t','a','x','E','r','r','o','r',0};
334  static const WCHAR TypeErrorW[] = {'T','y','p','e','E','r','r','o','r',0};
335  static const WCHAR URIErrorW[] = {'U','R','I','E','r','r','o','r',0};
336  static const WCHAR *names[] = {ErrorW, EvalErrorW, RangeErrorW,
338  jsdisp_t **constr_addr[] = {&ctx->error_constr, &ctx->eval_error_constr,
341  &ctx->uri_error_constr};
345 
346  jsdisp_t *err;
347  unsigned int i;
348  jsstr_t *str;
349  HRESULT hres;
350 
351  for(i=0; i < ARRAY_SIZE(names); i++) {
352  hres = alloc_error(ctx, i==0 ? object_prototype : NULL, NULL, &err);
353  if(FAILED(hres))
354  return hres;
355 
356  str = jsstr_alloc(names[i]);
357  if(!str) {
359  return E_OUTOFMEMORY;
360  }
361 
363  jsval_string(str));
365  if(SUCCEEDED(hres))
366  hres = create_builtin_constructor(ctx, constr_val[i], names[i], NULL,
367  PROPF_CONSTR|1, err, constr_addr[i]);
368 
370  if(FAILED(hres))
371  return hres;
372  }
373 
374  return S_OK;
375 }
#define PROPF_WRITABLE
Definition: jscript.h:98
static const WCHAR nameW[]
Definition: error.c:32
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
static const WCHAR RangeErrorW[]
Definition: global.c:39
static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:291
jsdisp_t * reference_error_constr
Definition: jscript.h:444
static const WCHAR EvalErrorW[]
Definition: global.c:38
static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:298
static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:277
static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:312
jsdisp_t * type_error_constr
Definition: jscript.h:447
static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:305
Definition: jsstr.h:39
jsdisp_t * range_error_constr
Definition: jscript.h:443
static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:319
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1794
#define PROPF_CONSTR
Definition: jscript.h:95
HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:679
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
jsdisp_t * syntax_error_constr
Definition: jscript.h:446
GLuint GLuint * names
Definition: glext.h:11545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
jsdisp_t * error_constr
Definition: jscript.h:441
jsdisp_t * regexp_error_constr
Definition: jscript.h:445
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR ErrorW[]
Definition: global.c:37
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
static const WCHAR TypeErrorW[]
Definition: global.c:42
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR SyntaxErrorW[]
Definition: global.c:41
LONG HRESULT
Definition: typedefs.h:77
static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:284
static const WCHAR URIErrorW[]
Definition: global.c:43
static const WCHAR ReferenceErrorW[]
Definition: global.c:40
#define err(...)
static HRESULT ErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:270
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
jsdisp_t * eval_error_constr
Definition: jscript.h:442
jsdisp_t * uri_error_constr
Definition: jscript.h:448
#define PROPF_CONFIGURABLE
Definition: jscript.h:99
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT(* builtin_invoke_t)(script_ctx_t *, vdisp_t *, WORD, unsigned, jsval_t *, jsval_t *)
Definition: jscript.h:200
static const WCHAR RegExpErrorW[]
Definition: global.c:49
static HRESULT alloc_error(script_ctx_t *ctx, jsdisp_t *prototype, jsdisp_t *constr, jsdisp_t **ret)
Definition: error.c:162

Referenced by init_constructors().

◆ RangeErrorConstr_value()

static HRESULT RangeErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 284 of file error.c.

286 {
287  TRACE("\n");
288  return error_constr(ctx, flags, argc, argv, r, ctx->range_error_constr);
289 }
static int argc
Definition: ServiceArgs.c:12
jsdisp_t * range_error_constr
Definition: jscript.h:443
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218

Referenced by init_error_constr().

◆ ReferenceErrorConstr_value()

static HRESULT ReferenceErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 291 of file error.c.

293 {
294  TRACE("\n");
295  return error_constr(ctx, flags, argc, argv, r, ctx->reference_error_constr);
296 }
static int argc
Definition: ServiceArgs.c:12
jsdisp_t * reference_error_constr
Definition: jscript.h:444
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218

Referenced by init_error_constr().

◆ RegExpErrorConstr_value()

static HRESULT RegExpErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 298 of file error.c.

300 {
301  TRACE("\n");
302  return error_constr(ctx, flags, argc, argv, r, ctx->regexp_error_constr);
303 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
jsdisp_t * regexp_error_constr
Definition: jscript.h:445
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218

Referenced by init_error_constr().

◆ SyntaxErrorConstr_value()

static HRESULT SyntaxErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 305 of file error.c.

307 {
308  TRACE("\n");
309  return error_constr(ctx, flags, argc, argv, r, ctx->syntax_error_constr);
310 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
jsdisp_t * syntax_error_constr
Definition: jscript.h:446
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218

Referenced by init_error_constr().

◆ throw_error()

static HRESULT throw_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str,
jsdisp_t constr 
)
static

Definition at line 377 of file error.c.

378 {
379  WCHAR buf[1024], *pos = NULL;
380  jsdisp_t *err;
381  jsstr_t *msg;
382  HRESULT hres;
383 
384  if(!is_jscript_error(error))
385  return error;
386 
387  buf[0] = '\0';
389 
390  if(str) pos = strchrW(buf, '|');
391  if(pos) {
392  int len = strlenW(str);
393  memmove(pos+len, pos+1, (strlenW(pos+1)+1)*sizeof(WCHAR));
394  memcpy(pos, str, len*sizeof(WCHAR));
395  }
396 
397  WARN("%s\n", debugstr_w(buf));
398 
399  msg = jsstr_alloc(buf);
400  if(!msg)
401  return E_OUTOFMEMORY;
402 
403  hres = create_error(ctx, constr, error, msg, &err);
405  if(FAILED(hres))
406  return hres;
407 
408  jsval_release(ctx->ei.val);
409  ctx->ei.val = jsval_obj(err);
410  return error;
411 }
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr, UINT number, jsstr_t *msg, jsdisp_t **ret)
Definition: error.c:186
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define WARN(fmt,...)
Definition: debug.h:111
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static BOOL is_jscript_error(HRESULT hres)
Definition: jscript.h:575
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
jsval_t val
Definition: jscript.h:396
HINSTANCE jscript_hinstance
Definition: jscript_main.c:39
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
#define ARRAY_SIZE(a)
Definition: main.h:24
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define msg(x)
Definition: auth_time.c:54
#define HRESULT_CODE(hr)
Definition: winerror.h:76
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46
jsexcept_t ei
Definition: jscript.h:420

Referenced by throw_generic_error(), throw_range_error(), throw_reference_error(), throw_regexp_error(), throw_syntax_error(), throw_type_error(), and throw_uri_error().

◆ throw_generic_error()

HRESULT throw_generic_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 413 of file error.c.

414 {
415  return throw_error(ctx, error, str, ctx->error_constr);
416 }
jsdisp_t * error_constr
Definition: jscript.h:441
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by ActiveXObject_value().

◆ throw_range_error()

HRESULT throw_range_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 418 of file error.c.

419 {
420  return throw_error(ctx, error, str, ctx->range_error_constr);
421 }
jsdisp_t * range_error_constr
Definition: jscript.h:443
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by Array_set_length(), ArrayConstr_value(), Number_toExponential(), Number_toFixed(), Number_toPrecision(), VBArray_getItem(), VBArray_lbound(), and VBArray_ubound().

◆ throw_reference_error()

HRESULT throw_reference_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 423 of file error.c.

424 {
425  return throw_error(ctx, error, str, ctx->reference_error_constr);
426 }
jsdisp_t * reference_error_constr
Definition: jscript.h:444
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by interp_assign(), interp_assign_call(), interp_refval(), and interp_throw_ref().

◆ throw_regexp_error()

HRESULT throw_regexp_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 428 of file error.c.

429 {
430  return throw_error(ctx, error, str, ctx->regexp_error_constr);
431 }
jsdisp_t * regexp_error_constr
Definition: jscript.h:445
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by RegExpConstr_value().

◆ throw_syntax_error()

HRESULT throw_syntax_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 433 of file error.c.

434 {
435  return throw_error(ctx, error, str, ctx->syntax_error_constr);
436 }
jsdisp_t * syntax_error_constr
Definition: jscript.h:446
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by JSGlobal_eval().

◆ throw_type_error()

HRESULT throw_type_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 438 of file error.c.

439 {
440  return throw_error(ctx, error, str, ctx->type_error_constr);
441 }
jsdisp_t * type_error_constr
Definition: jscript.h:447
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by Array_toString(), Bool_toString(), Bool_value(), Bool_valueOf(), create_utc_string(), Date_getDate(), Date_getDay(), Date_getFullYear(), Date_getHours(), Date_getMilliseconds(), Date_getMinutes(), Date_getMonth(), Date_getSeconds(), Date_getTime(), Date_getTimezoneOffset(), Date_getUTCDate(), Date_getUTCDay(), Date_getUTCFullYear(), Date_getUTCHours(), Date_getUTCMilliseconds(), Date_getUTCMinutes(), Date_getUTCMonth(), Date_getUTCSeconds(), Date_getYear(), Date_setDate(), Date_setFullYear(), Date_setHours(), Date_setMilliseconds(), Date_setMinutes(), Date_setMonth(), Date_setSeconds(), Date_setTime(), Date_setUTCDate(), Date_setUTCFullYear(), Date_setUTCHours(), Date_setUTCMilliseconds(), Date_setUTCMinutes(), Date_setUTCMonth(), Date_setUTCSeconds(), Date_setYear(), Date_toDateString(), Date_toISOString(), Date_toLocaleDateString(), Date_toLocaleString(), Date_toLocaleTimeString(), Date_toString(), Date_toTimeString(), Date_valueOf(), Error_value(), Function_apply(), Function_call(), Function_toString(), get_length(), identifier_value(), interp_call(), interp_call_member(), interp_in(), interp_instanceof(), interp_new(), interp_postinc(), interp_preinc(), interp_throw_type(), jsdisp_call_value(), jsdisp_define_property(), Number_toExponential(), Number_toFixed(), Number_toPrecision(), Number_toString(), Number_valueOf(), Object_defineProperty(), Object_getOwnPropertyDescriptor(), RegExp_value(), stack_pop_object(), to_object(), to_primitive(), to_property_descriptor(), VBArray_dimensions(), VBArray_getItem(), VBArray_lbound(), VBArray_toArray(), VBArray_ubound(), and VBArrayConstr_value().

◆ throw_uri_error()

HRESULT throw_uri_error ( script_ctx_t ctx,
HRESULT  error,
const WCHAR str 
)

Definition at line 443 of file error.c.

444 {
445  return throw_error(ctx, error, str, ctx->uri_error_constr);
446 }
const WCHAR * str
static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
Definition: error.c:377
jsdisp_t * uri_error_constr
Definition: jscript.h:448
EXPORT int error(char *fmt, va_alist)
Definition: error.c:46

Referenced by JSGlobal_decodeURI(), JSGlobal_encodeURI(), and JSGlobal_encodeURIComponent().

◆ TypeErrorConstr_value()

static HRESULT TypeErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 312 of file error.c.

314 {
315  TRACE("\n");
316  return error_constr(ctx, flags, argc, argv, r, ctx->type_error_constr);
317 }
static int argc
Definition: ServiceArgs.c:12
jsdisp_t * type_error_constr
Definition: jscript.h:447
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218

Referenced by init_error_constr().

◆ URIErrorConstr_value()

static HRESULT URIErrorConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 319 of file error.c.

321 {
322  TRACE("\n");
323  return error_constr(ctx, flags, argc, argv, r, ctx->uri_error_constr);
324 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsdisp_t *constr)
Definition: error.c:218
jsdisp_t * uri_error_constr
Definition: jscript.h:448

Referenced by init_error_constr().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ descriptionW

const WCHAR descriptionW[] = {'d','e','s','c','r','i','p','t','i','o','n',0}
static

◆ Error_info

const builtin_info_t Error_info
static
Initial value:
= {
}
static HRESULT Error_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:124
smooth NULL
Definition: ftsmooth.c:416
static const builtin_prop_t Error_props[]
Definition: error.c:140
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 144 of file error.c.

Referenced by alloc_error().

◆ Error_props

const builtin_prop_t Error_props[]
static
Initial value:
= {
}
static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:37
static const WCHAR toStringW[]
Definition: error.c:34
#define PROPF_METHOD
Definition: jscript.h:94

Definition at line 140 of file error.c.

◆ ErrorInst_info

const builtin_info_t ErrorInst_info
static
Initial value:
= {
0,
}
static HRESULT Error_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: error.c:124
smooth NULL
Definition: ftsmooth.c:416

Definition at line 153 of file error.c.

Referenced by alloc_error().

◆ messageW

const WCHAR messageW[] = {'m','e','s','s','a','g','e',0}
static

Definition at line 31 of file error.c.

Referenced by create_error(), Error_toString(), MAPISendMail(), and unwind_exception().

◆ nameW

const WCHAR nameW[] = {'n','a','m','e',0}
static

Definition at line 32 of file error.c.

Referenced by Error_toString(), and init_error_constr().

◆ numberW

const WCHAR numberW[] = {'n','u','m','b','e','r',0}
static

Definition at line 33 of file error.c.

Referenced by create_error().

◆ toStringW

const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}
static

Definition at line 34 of file error.c.