mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 06:06:13 +00:00
jscript: Support propagating error message.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0f4d4f7184
commit
bcba07229a
5 changed files with 22 additions and 3 deletions
|
@ -1978,6 +1978,8 @@ static HRESULT disp_invoke(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD f
|
|||
ctx->ei->error = (SUCCEEDED(ei.scode) || ei.scode == DISP_E_EXCEPTION) ? E_FAIL : ei.scode;
|
||||
if(ei.bstrSource)
|
||||
ctx->ei->source = jsstr_alloc_len(ei.bstrSource, SysStringLen(ei.bstrSource));
|
||||
if(ei.bstrDescription)
|
||||
ctx->ei->message = jsstr_alloc_len(ei.bstrDescription, SysStringLen(ei.bstrDescription));
|
||||
SysFreeString(ei.bstrSource);
|
||||
SysFreeString(ei.bstrDescription);
|
||||
SysFreeString(ei.bstrHelpFile);
|
||||
|
|
|
@ -867,6 +867,7 @@ static void set_error_value(script_ctx_t *ctx, jsval_t value)
|
|||
|
||||
if(is_object_instance(value) && get_object(value) && (obj = to_jsdisp(get_object(value)))) {
|
||||
UINT32 number;
|
||||
jsstr_t *str;
|
||||
jsval_t v;
|
||||
HRESULT hres;
|
||||
|
||||
|
@ -879,8 +880,15 @@ static void set_error_value(script_ctx_t *ctx, jsval_t value)
|
|||
ei->error = FAILED(number) ? number : E_FAIL;
|
||||
jsval_release(v);
|
||||
}
|
||||
}
|
||||
|
||||
hres = jsdisp_propget_name(obj, L"description", &v);
|
||||
if(SUCCEEDED(hres)) {
|
||||
hres = to_string(ctx, v, &str);
|
||||
if(SUCCEEDED(hres))
|
||||
ei->message = str;
|
||||
jsval_release(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 12.13 */
|
||||
|
@ -2769,8 +2777,10 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres)
|
|||
}
|
||||
|
||||
frame = ctx->call_ctx;
|
||||
if(exception_hres != DISP_E_EXCEPTION)
|
||||
if(exception_hres != DISP_E_EXCEPTION) {
|
||||
reset_ei(ei);
|
||||
ei->error = exception_hres;
|
||||
}
|
||||
set_error_location(ei, frame->bytecode, frame->bytecode->instrs[frame->ip].loc, IDS_RUNTIME_ERROR);
|
||||
|
||||
while(!frame->except_frame) {
|
||||
|
|
|
@ -228,6 +228,7 @@ struct _jsexcept_t {
|
|||
jsval_t value;
|
||||
|
||||
jsstr_t *source;
|
||||
jsstr_t *message;
|
||||
|
||||
bytecode_t *code;
|
||||
unsigned loc;
|
||||
|
|
|
@ -455,6 +455,8 @@ void set_error_location(jsexcept_t *ei, bytecode_t *code, unsigned loc, unsigned
|
|||
len = LoadStringW(jscript_hinstance, source_id, (WCHAR*)&res, 0);
|
||||
ei->source = jsstr_alloc_len(res, len);
|
||||
}
|
||||
if(!ei->message)
|
||||
ei->message = format_error_message(ei->error, NULL);
|
||||
}
|
||||
|
||||
TRACE("source %s in %s\n", debugstr_w(code->source + loc), debugstr_w(code->source));
|
||||
|
@ -538,6 +540,6 @@ jsdisp_t *create_builtin_error(script_ctx_t *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
hres = create_error(ctx, constr, ei->error, jsstr_empty(), &r);
|
||||
hres = create_error(ctx, constr, ei->error, ei->message ? ei->message : jsstr_empty(), &r);
|
||||
return SUCCEEDED(hres) ? r : NULL;
|
||||
}
|
||||
|
|
|
@ -223,6 +223,10 @@ void reset_ei(jsexcept_t *ei)
|
|||
jsstr_release(ei->source);
|
||||
ei->source = NULL;
|
||||
}
|
||||
if(ei->message) {
|
||||
jsstr_release(ei->message);
|
||||
ei->message = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void enter_script(script_ctx_t *ctx, jsexcept_t *ei)
|
||||
|
|
Loading…
Reference in a new issue