dom/bindings/Exceptions.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:8a78bf92014f
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/. */
5
6 #ifndef mozilla_dom_Exceptions_h__
7 #define mozilla_dom_Exceptions_h__
8
9 // DOM exception throwing machinery (for both main thread and workers).
10
11 #include <stdint.h>
12 #include "jspubtd.h"
13 #include "nsIException.h"
14
15 class nsIStackFrame;
16 template <class T>
17 class already_AddRefed;
18
19 namespace mozilla {
20 namespace dom {
21
22 class Exception;
23
24 bool
25 Throw(JSContext* cx, nsresult rv, const char* sz = nullptr);
26
27 bool
28 ThrowExceptionObject(JSContext* aCx, Exception* aException);
29
30 bool
31 ThrowExceptionObject(JSContext* aCx, nsIException* aException);
32
33 // Create an exception object for the given nsresult and message but
34 // don't set it pending on aCx. This never returns null.
35 already_AddRefed<Exception>
36 CreateException(JSContext* aCx, nsresult aRv, const char* aMessage = nullptr);
37
38 already_AddRefed<nsIStackFrame>
39 GetCurrentJSStack();
40
41 // Internal stuff not intended to be widely used.
42 namespace exceptions {
43
44 // aMaxDepth can be used to define a maximal depth for the stack trace. If the
45 // value is -1, a default maximal depth will be selected.
46 already_AddRefed<nsIStackFrame>
47 CreateStack(JSContext* aCx, int32_t aMaxDepth = -1);
48
49 already_AddRefed<nsIStackFrame>
50 CreateStackFrameLocation(uint32_t aLanguage,
51 const char* aFilename,
52 const char* aFunctionName,
53 int32_t aLineNumber,
54 nsIStackFrame* aCaller);
55
56 } // namespace exceptions
57 } // namespace dom
58 } // namespace mozilla
59
60 #endif

mercurial