michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_Exceptions_h__ michael@0: #define mozilla_dom_Exceptions_h__ michael@0: michael@0: // DOM exception throwing machinery (for both main thread and workers). michael@0: michael@0: #include michael@0: #include "jspubtd.h" michael@0: #include "nsIException.h" michael@0: michael@0: class nsIStackFrame; michael@0: template michael@0: class already_AddRefed; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class Exception; michael@0: michael@0: bool michael@0: Throw(JSContext* cx, nsresult rv, const char* sz = nullptr); michael@0: michael@0: bool michael@0: ThrowExceptionObject(JSContext* aCx, Exception* aException); michael@0: michael@0: bool michael@0: ThrowExceptionObject(JSContext* aCx, nsIException* aException); michael@0: michael@0: // Create an exception object for the given nsresult and message but michael@0: // don't set it pending on aCx. This never returns null. michael@0: already_AddRefed michael@0: CreateException(JSContext* aCx, nsresult aRv, const char* aMessage = nullptr); michael@0: michael@0: already_AddRefed michael@0: GetCurrentJSStack(); michael@0: michael@0: // Internal stuff not intended to be widely used. michael@0: namespace exceptions { michael@0: michael@0: // aMaxDepth can be used to define a maximal depth for the stack trace. If the michael@0: // value is -1, a default maximal depth will be selected. michael@0: already_AddRefed michael@0: CreateStack(JSContext* aCx, int32_t aMaxDepth = -1); michael@0: michael@0: already_AddRefed michael@0: CreateStackFrameLocation(uint32_t aLanguage, michael@0: const char* aFilename, michael@0: const char* aFunctionName, michael@0: int32_t aLineNumber, michael@0: nsIStackFrame* aCaller); michael@0: michael@0: } // namespace exceptions michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif