mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 743049 - Part 1: Add a friend API to get an error type name from a number. r=luke
This commit is contained in:
parent
8152b2083e
commit
5ca99795f4
@ -1096,6 +1096,27 @@ js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *locale,
|
||||
return errorString;
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
JS_FRIEND_API(const jschar*)
|
||||
GetErrorTypeNameFromNumber(JSContext* cx, const unsigned errorNumber)
|
||||
{
|
||||
const JSErrorFormatString *efs = js_GetErrorMessage(NULL, NULL, errorNumber);
|
||||
/*
|
||||
* JSEXN_INTERNALERR returns null to prevent that "InternalError: "
|
||||
* is prepended before "uncaught exception: "
|
||||
*/
|
||||
if (!efs || efs->exnType <= JSEXN_NONE || efs->exnType >= JSEXN_LIMIT ||
|
||||
efs->exnType == JSEXN_INTERNALERR)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
JSProtoKey key = GetExceptionProtoKey(efs->exnType);
|
||||
return cx->runtime->atomState.classAtoms[key]->chars();
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#if defined ( DEBUG_mccabe ) && defined ( PRINTNAMES )
|
||||
/* For use below... get character strings for error name and exception name */
|
||||
static struct exnname { char *name; char *exception; } errortoexnname[] = {
|
||||
|
@ -792,6 +792,15 @@ CastToJSFreeOp(FreeOp *fop)
|
||||
return reinterpret_cast<JSFreeOp *>(fop);
|
||||
}
|
||||
|
||||
/* Implemented in jsexn.cpp. */
|
||||
|
||||
/*
|
||||
* Get an error type name from a number.
|
||||
* If no exception is associated, return NULL.
|
||||
*/
|
||||
extern JS_FRIEND_API(const jschar*)
|
||||
GetErrorTypeNameFromNumber(JSContext* cx, const unsigned errorNumber);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user