1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
7 * Interfaces for representing cross-language exceptions and stack traces.
9 #include
"nsISupports.idl"
11 [ptr] native JSContext
(JSContext
);
12 native StackFrameRef
(already_AddRefed
<nsIStackFrame
>);
14 [scriptable
, builtinclass
, uuid(28bfb2a2
-5ea6
-4738-918b
-049dc4d51f0b
)]
15 interface nsIStackFrame
: nsISupports
17 [implicit_jscontext
, binaryname
(FilenameXPCOM
)]
18 readonly attribute AUTF8String filename
;
19 [implicit_jscontext
, binaryname
(NameXPCOM
)]
20 readonly attribute AString name
;
21 // Unique identifier of the script source for the frame, or zero.
22 [implicit_jscontext
, binaryname
(SourceIdXPCOM
)]
23 readonly attribute int32_t sourceId
;
24 // Valid line numbers begin at '1'. '0' indicates unknown.
25 [implicit_jscontext
, binaryname
(LineNumberXPCOM
)]
26 readonly attribute int32_t lineNumber
;
27 [implicit_jscontext
, binaryname
(ColumnNumberXPCOM
)]
28 readonly attribute int32_t columnNumber
;
29 [implicit_jscontext
, binaryname
(AsyncCauseXPCOM
)]
30 readonly attribute AString asyncCause
;
31 [implicit_jscontext
, binaryname
(AsyncCallerXPCOM
)]
32 readonly attribute nsIStackFrame asyncCaller
;
33 [implicit_jscontext
, binaryname
(CallerXPCOM
)]
34 readonly attribute nsIStackFrame caller
;
36 // Returns a formatted stack string that looks like the sort of
37 // string that would be returned by .stack on JS Error objects.
38 // Only works on JS-language stack frames.
39 [implicit_jscontext
, binaryname
(FormattedStackXPCOM
)]
40 readonly attribute AString formattedStack
;
42 // Returns the underlying SavedFrame object for native JavaScript stacks,
43 // or null if this is not a native JavaScript stack frame.
44 readonly attribute jsval nativeSavedFrame
;
46 [implicit_jscontext
, binaryname
(ToStringXPCOM
)]
47 AUTF8String toString
();
49 // Infallible things to be called from C++.
51 void getFilename
(in JSContext aCx
, out AUTF8String aFilename
);
53 void getName
(in JSContext aCx
, out AString aName
);
55 int32_t getSourceId
(in JSContext aCx
);
57 int32_t getLineNumber
(in JSContext aCx
);
59 int32_t getColumnNumber
(in JSContext aCx
);
61 void getAsyncCause
(in JSContext aCx
, out AString aAsyncCause
);
63 StackFrameRef getAsyncCaller
(in JSContext aCx
);
65 StackFrameRef getCaller
(in JSContext aCx
);
67 void getFormattedStack
(in JSContext aCx
, out AString aFormattedStack
);
68 [notxpcom
, nostdcall
, binaryname
(ToString
)]
69 void toStringInfallible
(in JSContext aCx
, out AUTF8String aString
);
72 // This interface only exists because of all the JS consumers doing
73 // "instanceof Ci.nsIException". We should switch them to something else and
74 // get rid of it; bug 1435856 tracks that. C++ code should NOT use this; use
75 // mozilla::dom::Exception instead.
76 [scriptable
, builtinclass
, uuid(4371b5bf
-6845-487f
-8d9d
-3f1e4a9badd2
)]
77 interface nsIException
: nsISupports