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).
13 #include "nsIException.h"
18 struct already_AddRefed
;
26 Throw(JSContext
* cx
, nsresult rv
, const char* sz
= nullptr);
28 // Create, throw and report an exception to a given window.
30 ThrowAndReport(nsPIDOMWindow
* aWindow
, nsresult aRv
,
31 const char* aMessage
= nullptr);
34 ThrowExceptionObject(JSContext
* aCx
, Exception
* aException
);
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
>
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
,
60 nsIStackFrame
* aCaller
);
62 } // namespace exceptions
64 } // namespace mozilla