1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bindings/Exceptions.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_dom_Exceptions_h__ 1.10 +#define mozilla_dom_Exceptions_h__ 1.11 + 1.12 +// DOM exception throwing machinery (for both main thread and workers). 1.13 + 1.14 +#include <stdint.h> 1.15 +#include "jspubtd.h" 1.16 +#include "nsIException.h" 1.17 + 1.18 +class nsIStackFrame; 1.19 +template <class T> 1.20 +class already_AddRefed; 1.21 + 1.22 +namespace mozilla { 1.23 +namespace dom { 1.24 + 1.25 +class Exception; 1.26 + 1.27 +bool 1.28 +Throw(JSContext* cx, nsresult rv, const char* sz = nullptr); 1.29 + 1.30 +bool 1.31 +ThrowExceptionObject(JSContext* aCx, Exception* aException); 1.32 + 1.33 +bool 1.34 +ThrowExceptionObject(JSContext* aCx, nsIException* aException); 1.35 + 1.36 +// Create an exception object for the given nsresult and message but 1.37 +// don't set it pending on aCx. This never returns null. 1.38 +already_AddRefed<Exception> 1.39 +CreateException(JSContext* aCx, nsresult aRv, const char* aMessage = nullptr); 1.40 + 1.41 +already_AddRefed<nsIStackFrame> 1.42 +GetCurrentJSStack(); 1.43 + 1.44 +// Internal stuff not intended to be widely used. 1.45 +namespace exceptions { 1.46 + 1.47 +// aMaxDepth can be used to define a maximal depth for the stack trace. If the 1.48 +// value is -1, a default maximal depth will be selected. 1.49 +already_AddRefed<nsIStackFrame> 1.50 +CreateStack(JSContext* aCx, int32_t aMaxDepth = -1); 1.51 + 1.52 +already_AddRefed<nsIStackFrame> 1.53 +CreateStackFrameLocation(uint32_t aLanguage, 1.54 + const char* aFilename, 1.55 + const char* aFunctionName, 1.56 + int32_t aLineNumber, 1.57 + nsIStackFrame* aCaller); 1.58 + 1.59 +} // namespace exceptions 1.60 +} // namespace dom 1.61 +} // namespace mozilla 1.62 + 1.63 +#endif