Reporting API
The set() method of the CrashReportContext interface stores a key-value pair in the memory initialized by CrashReportContext.initialize.
Syntax
set(key, value)
Parameters
key- : A string representing the key of the key-value pair to be stored.
value- : A string representing the value of the key-value pair to be stored.
Return value
None (undefined).
Exceptions
InvalidStateErrorDOMException- : Thrown if:
- The calling document is not fully active.
- The crash report key-value store is not yet initialized via an CrashReportContext.initialize call.
- : Thrown if:
NotAllowedErrorDOMException- : The size of the serialized key-value pair is greater than the
lengthvalue set when the store was first initialized.
- : The size of the serialized key-value pair is greater than the
Examples
Basic usage
window.crashReport.initialize(1024).then(() => {
// Set a possible crash-causing value, and try
// running an operation that may cause a crash
window.crashReport.set("crash-arg", "00031");
operationThatMightCrash("00031");
// Delete the key-value pair if it doesn't cause a crash
window.crashReport.delete("crash-arg");
});
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
