jscript: Pass msg as jsstr_t to create_error.

This commit is contained in:
Jacek Caban 2013-03-08 11:37:30 +01:00 committed by Alexandre Julliard
parent b8e2edf19c
commit c7c71b87b8
1 changed files with 21 additions and 21 deletions

View File

@ -180,10 +180,9 @@ static HRESULT alloc_error(script_ctx_t *ctx, jsdisp_t *prototype,
} }
static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr, static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
UINT number, const WCHAR *msg, jsdisp_t **ret) UINT number, jsstr_t *msg, jsdisp_t **ret)
{ {
jsdisp_t *err; jsdisp_t *err;
jsstr_t *str;
HRESULT hres; HRESULT hres;
hres = alloc_error(ctx, NULL, constr, &err); hres = alloc_error(ctx, NULL, constr, &err);
@ -196,16 +195,9 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
return hres; return hres;
} }
if(msg) str = jsstr_alloc(msg); hres = jsdisp_propput_name(err, messageW, jsval_string(msg));
else str = jsstr_empty(); if(SUCCEEDED(hres))
if(str) { hres = jsdisp_propput_dontenum(err, descriptionW, jsval_string(msg));
hres = jsdisp_propput_name(err, messageW, jsval_string(str));
if(SUCCEEDED(hres))
hres = jsdisp_propput_dontenum(err, descriptionW, jsval_string(str));
jsstr_release(str);
}else {
hres = E_OUTOFMEMORY;
}
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(err); jsdisp_release(err);
return hres; return hres;
@ -235,19 +227,21 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_
num = n; num = n;
} }
if(argc>1 && !msg) { if(!msg) {
hres = to_string(ctx, argv[1], &msg); if(argc > 1) {
if(FAILED(hres)) hres = to_string(ctx, argv[1], &msg);
return hres; if(FAILED(hres))
return hres;
}else {
msg = jsstr_empty();
}
} }
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
case DISPATCH_CONSTRUCT: case DISPATCH_CONSTRUCT:
hres = create_error(ctx, constr, num, msg ? msg->str : NULL, &err); hres = create_error(ctx, constr, num, msg, &err);
if(msg) jsstr_release(msg);
jsstr_release(msg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -375,6 +369,7 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j
{ {
WCHAR buf[1024], *pos = NULL; WCHAR buf[1024], *pos = NULL;
jsdisp_t *err; jsdisp_t *err;
jsstr_t *msg;
HRESULT hres; HRESULT hres;
if(!is_jscript_error(error)) if(!is_jscript_error(error))
@ -392,7 +387,12 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j
WARN("%s\n", debugstr_w(buf)); WARN("%s\n", debugstr_w(buf));
hres = create_error(ctx, constr, error, buf, &err); msg = jsstr_alloc(buf);
if(!msg)
return E_OUTOFMEMORY;
hres = create_error(ctx, constr, error, msg, &err);
jsstr_release(msg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;