Bumping manifests a=b2g-bump
[gecko.git] / dom / bindings / Exceptions.h
bloba476b7dd437544f70ac251a44f251cbc2f0f4fe3
1 /* -*- Mode: C++; tab-width: 2; 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 mozilla_dom_Exceptions_h__
7 #define mozilla_dom_Exceptions_h__
9 // DOM exception throwing machinery (for both main thread and workers).
11 #include <stdint.h>
12 #include "jspubtd.h"
13 #include "nsIException.h"
15 class nsIStackFrame;
16 class nsPIDOMWindow;
17 template <class T>
18 struct already_AddRefed;
20 namespace mozilla {
21 namespace dom {
23 class Exception;
25 bool
26 Throw(JSContext* cx, nsresult rv, const char* sz = nullptr);
28 // Create, throw and report an exception to a given window.
29 void
30 ThrowAndReport(nsPIDOMWindow* aWindow, nsresult aRv,
31 const char* aMessage = nullptr);
33 bool
34 ThrowExceptionObject(JSContext* aCx, Exception* aException);
36 bool
37 ThrowExceptionObject(JSContext* aCx, nsIException* aException);
39 // Create an exception object for the given nsresult and message but
40 // don't set it pending on aCx. This never returns null.
41 already_AddRefed<Exception>
42 CreateException(JSContext* aCx, nsresult aRv, const char* aMessage = nullptr);
44 already_AddRefed<nsIStackFrame>
45 GetCurrentJSStack();
47 // Internal stuff not intended to be widely used.
48 namespace exceptions {
50 // aMaxDepth can be used to define a maximal depth for the stack trace. If the
51 // value is -1, a default maximal depth will be selected.
52 already_AddRefed<nsIStackFrame>
53 CreateStack(JSContext* aCx, int32_t aMaxDepth = -1);
55 already_AddRefed<nsIStackFrame>
56 CreateStackFrameLocation(uint32_t aLanguage,
57 const char* aFilename,
58 const char* aFunctionName,
59 int32_t aLineNumber,
60 nsIStackFrame* aCaller);
62 } // namespace exceptions
63 } // namespace dom
64 } // namespace mozilla
66 #endif