mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
1283712 - Part 9: Add getErrorNotes testing function to extract error notes from exception.
This commit is contained in:
parent
624a2f1b61
commit
9ab58a4769
1 changed files with 30 additions and 0 deletions
|
|
@ -4043,6 +4043,32 @@ IsConstructor(JSContext* cx, unsigned argc, Value* vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetErrorNotes(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (!args.requireAtLeast(cx, "getErrorNotes", 1))
|
||||
return false;
|
||||
|
||||
if (!args[0].isObject() || !args[0].toObject().is<ErrorObject>()) {
|
||||
args.rval().setNull();
|
||||
return true;
|
||||
}
|
||||
|
||||
JSErrorReport* report = args[0].toObject().as<ErrorObject>().getErrorReport();
|
||||
if (!report) {
|
||||
args.rval().setNull();
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedObject notesArray(cx, CreateErrorNotesArray(cx, report));
|
||||
if (!notesArray)
|
||||
return false;
|
||||
|
||||
args.rval().setObject(*notesArray);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const JSFunctionSpecWithHelp TestingFunctions[] = {
|
||||
JS_FN_HELP("gc", ::GC, 0, 0,
|
||||
"gc([obj] | 'zone' [, 'shrinking'])",
|
||||
|
|
@ -4577,6 +4603,10 @@ static const JSFunctionSpecWithHelp FuzzingUnsafeTestingFunctions[] = {
|
|||
" Dumps RegExp bytecode."),
|
||||
#endif
|
||||
|
||||
JS_FN_HELP("getErrorNotes", GetErrorNotes, 1, 0,
|
||||
"getErrorNotes(error)",
|
||||
" Returns an array of error notes."),
|
||||
|
||||
JS_FS_HELP_END
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue