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 AString 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 readonly attribute AUTF8String sourceLine
;
30 [implicit_jscontext
, binaryname
(AsyncCauseXPCOM
)]
31 readonly attribute AString asyncCause
;
32 [implicit_jscontext
, binaryname
(AsyncCallerXPCOM
)]
33 readonly attribute nsIStackFrame asyncCaller
;
34 [implicit_jscontext
, binaryname
(CallerXPCOM
)]
35 readonly attribute nsIStackFrame caller
;
37 // Returns a formatted stack string that looks like the sort of
38 // string that would be returned by .stack on JS Error objects.
39 // Only works on JS-language stack frames.
40 [implicit_jscontext
, binaryname
(FormattedStackXPCOM
)]
41 readonly attribute AString formattedStack
;
43 // Returns the underlying SavedFrame object for native JavaScript stacks,
44 // or null if this is not a native JavaScript stack frame.
45 readonly attribute jsval nativeSavedFrame
;
47 [implicit_jscontext
, binaryname
(ToStringXPCOM
)]
48 AUTF8String toString
();
50 // Infallible things to be called from C++.
52 void getFilename
(in JSContext aCx
, out AString aFilename
);
54 void getName
(in JSContext aCx
, out AString aName
);
56 int32_t getSourceId
(in JSContext aCx
);
58 int32_t getLineNumber
(in JSContext aCx
);
60 int32_t getColumnNumber
(in JSContext aCx
);
62 void getAsyncCause
(in JSContext aCx
, out AString aAsyncCause
);
64 StackFrameRef getAsyncCaller
(in JSContext aCx
);
66 StackFrameRef getCaller
(in JSContext aCx
);
68 void getFormattedStack
(in JSContext aCx
, out AString aFormattedStack
);
69 [notxpcom
, nostdcall
, binaryname
(ToString
)]
70 void toStringInfallible
(in JSContext aCx
, out AUTF8String aString
);
73 // This interface only exists because of all the JS consumers doing
74 // "instanceof Ci.nsIException". We should switch them to something else and
75 // get rid of it; bug 1435856 tracks that. C++ code should NOT use this; use
76 // mozilla::dom::Exception instead.
77 [scriptable
, builtinclass
, uuid(4371b5bf
-6845-487f
-8d9d
-3f1e4a9badd2
)]
78 interface nsIException
: nsISupports