Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / js / public / ErrorInterceptor.h
blob7481c48fcb3a3ce820e143371e73448c30396a28
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef js_ErrorInterceptor_h
7 #define js_ErrorInterceptor_h
9 #include "jstypes.h"
11 #include "js/TypeDecls.h"
13 /**
14 * Callback used to intercept JavaScript errors.
16 struct JSErrorInterceptor {
17 /**
18 * This method is called whenever an error has been raised from JS code.
20 * This method MUST be infallible.
22 virtual void interceptError(JSContext* cx, JS::HandleValue error) = 0;
25 // Set a callback that will be called whenever an error
26 // is thrown in this runtime. This is designed as a mechanism
27 // for logging errors. Note that the VM makes no attempt to sanitize
28 // the contents of the error (so it may contain private data)
29 // or to sort out among errors (so it may not be the error you
30 // are interested in or for the component in which you are
31 // interested).
33 // If the callback sets a new error, this new error
34 // will replace the original error.
36 // May be `nullptr`.
37 // This is a no-op if built without NIGHTLY_BUILD.
38 extern JS_PUBLIC_API void JS_SetErrorInterceptorCallback(
39 JSRuntime*, JSErrorInterceptor* callback);
41 // This returns nullptr if built without NIGHTLY_BUILD.
42 extern JS_PUBLIC_API JSErrorInterceptor* JS_GetErrorInterceptorCallback(
43 JSRuntime*);
45 #endif // js_ErrorInterceptor_h