Commit c7c71b87 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Pass msg as jsstr_t to create_error.

parent b8e2edf1
...@@ -180,10 +180,9 @@ static HRESULT alloc_error(script_ctx_t *ctx, jsdisp_t *prototype, ...@@ -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, ...@@ -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_ ...@@ -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 ...@@ -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 ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment