Skip to content

Commit 5096089

Browse files
committed
chore: Exception, Machanism, Stacktrace, Stackframe improvments
- JSDoc added - MechanismMeta added
1 parent 83c2c0a commit 5096089

File tree

5 files changed

+309
-16
lines changed

5 files changed

+309
-16
lines changed

packages/types/src/exception.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
import { Mechanism } from './mechanism';
22
import { Stacktrace } from './stacktrace';
33

4-
/** JSDoc */
4+
/**
5+
* The Exception Interface specifies an exception or error that occurred in a program.
6+
* @external https://develop.sentry.dev/sdk/event-payloads/exception/
7+
*/
58
export interface Exception {
6-
type?: string;
7-
value?: string;
8-
mechanism?: Mechanism;
9+
/**
10+
* The type of exception, e.g. ValueError.
11+
*/
12+
type: string;
13+
14+
/**
15+
* The value of the exception.
16+
*/
17+
value: string;
18+
19+
/**
20+
* The module, or package which the exception type lives in.
21+
*/
922
module?: string;
23+
24+
/**
25+
* An value which refers to a thread in the Threads Interface.
26+
*/
1027
thread_id?: number;
28+
29+
/**
30+
* An object describing the mechanism that created this exception.
31+
*/
32+
mechanism?: Mechanism;
33+
34+
/**
35+
* An stack trace object corresponding to the Stack Trace Interface.
36+
*/
1137
stacktrace?: Stacktrace;
1238
}

packages/types/src/mechanism.ts

Lines changed: 129 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,133 @@
1-
/** JSDoc */
1+
/**
2+
* @external https://develop.sentry.dev/sdk/event-payloads/exception/#exception-mechanism
3+
*/
24
export interface Mechanism {
5+
/**
6+
* Unique identifier of this mechanism determining rendering and processing of the mechanism data.
7+
*/
38
type: string;
4-
handled: boolean;
5-
data?: {
6-
[key: string]: string | boolean;
7-
};
9+
10+
/**
11+
* Human-readable description of the error mechanism and a possible hint on how to solve this error.
12+
*/
13+
description?: string;
14+
15+
/**
16+
* Human-readable description of the error mechanism and a possible hint on how to solve this error.
17+
*/
18+
helpLink?: string;
19+
20+
/**
21+
* Flag indicating whether the user has handled the exception (for example, via try ... catch).
22+
*/
23+
handled?: boolean;
24+
25+
/**
26+
* An flag indicating that this error is synthetic.
27+
* Synthetic errors are errors that carry little meaning by themselves.
28+
* This may be because they are created at a central place (like a crash handler),
29+
* and are all called the same: Error, Segfault etc.
30+
* When the flag is set,
31+
* Sentry will then try to use other information (top in-app frame function)
32+
* rather than exception type and value in the UI for the primary event display.
33+
* This flag should be set for all "segfaults" for instance as every
34+
* single error group would look very similar otherwise.
35+
*/
836
synthetic?: boolean;
37+
38+
/**
39+
* Information from the operating system or runtime on the exception mechanism.
40+
*/
41+
meta?: MechanismMeta;
42+
43+
/**
44+
* Arbitrary extra data that might help the user understand the error thrown by this mechanism.
45+
*/
46+
data?: Record<string, unknown>;
47+
}
48+
49+
export interface MechanismMeta {
50+
/**
51+
* Information on the POSIX signal.
52+
* On Apple systems, signals also carry a code in addition to the signal number describing the signal in more detail.
53+
* On Linux, this code does not exist.
54+
*/
55+
signal?: MechanismMetaSignal;
56+
57+
/**
58+
* A Mach Exception on Apple systems comprising a code triple and optional descriptions.
59+
*/
60+
mach_exception?: MechanismMetaMachException;
61+
62+
/**
63+
* Error codes set by Linux system calls and some library functions as
64+
* specified in ISO C99, POSIX.1-2001, and POSIX.1-2008.
65+
* See errno(3) for more information.
66+
*/
67+
errno?: MechanismMetaErrorNo;
68+
}
69+
70+
/**
71+
* @external https://develop.sentry.dev/sdk/event-payloads/exception/#meta-information
72+
*/
73+
export interface MechanismMetaSignal {
74+
/**
75+
* The POSIX signal number.
76+
*/
77+
number: number;
78+
79+
/**
80+
* Apple signal code.
81+
*/
82+
code?: string;
83+
84+
/**
85+
* Name of the signal based on the signal number.
86+
*/
87+
name?: string;
88+
89+
/**
90+
* Name of the signal code.
91+
*/
92+
code_name?: string;
93+
}
94+
95+
/**
96+
* @external https://develop.sentry.dev/sdk/event-payloads/exception/#meta-information
97+
*/
98+
export interface MechanismMetaMachException {
99+
/**
100+
* Numeric exception number.
101+
*/
102+
exception: number;
103+
104+
/**
105+
* Numeric exception code.
106+
*/
107+
code: number;
108+
109+
/**
110+
* Numeric exception subcode.
111+
*/
112+
subcode: number;
113+
114+
/**
115+
* Name of the exception constant in iOS / macOS.
116+
*/
117+
name?: string;
118+
}
119+
120+
/**
121+
* @external https://develop.sentry.dev/sdk/event-payloads/exception/#meta-information
122+
*/
123+
export interface MechanismMetaErrorNo {
124+
/**
125+
* The error number
126+
*/
127+
number: number;
128+
129+
/**
130+
* Name of the error
131+
*/
132+
name?: string;
9133
}

packages/types/src/stackframe.ts

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,116 @@
1-
/** JSDoc */
1+
/**
2+
* @external https://develop.sentry.dev/sdk/event-payloads/stacktrace/#frame-attributes
3+
*/
24
export interface StackFrame {
5+
/**
6+
* The path to the source file relative to the project root directory.
7+
* The value should not make file names indistinguishable and should only change between releases for files that were actually renamed.
8+
* In some SDKs, this is implemented as the path relative to a certain entry point relevant to the language/platform.
9+
*/
310
filename?: string;
11+
12+
/**
13+
* The name of the function being called.
14+
* This function name may be shortened or demangled. If not, Sentry will demangle and shorten it.
15+
* The original function name will be stored in rawFunction.
16+
*/
417
function?: string;
18+
19+
/**
20+
* The original function name, if the function name is shortened or demangled.
21+
* Sentry shows the raw function when clicking on the shortened one in the UI.
22+
*/
23+
raw_function?: string;
24+
25+
/**
26+
* Platform-specific module path (e.g. sentry.interfaces.Stacktrace).
27+
*/
528
module?: string;
6-
platform?: string;
29+
30+
/**
31+
* The line number of the call, starting at 1.
32+
*/
733
lineno?: number;
34+
35+
/**
36+
* The column number of the call, starting at 1.
37+
*/
838
colno?: number;
39+
40+
/**
41+
* The absolute path to the source file.
42+
*/
943
abs_path?: string;
44+
45+
/**
46+
* Source code in filename at lineno.
47+
*/
1048
context_line?: string;
49+
50+
/**
51+
* A list of source code lines before context_line (in order) –
52+
* usually [lineno - 5:lineno].
53+
*/
1154
pre_context?: string[];
55+
56+
/**
57+
* A list of source code lines after context_line (in order) –
58+
* usually [lineno + 1:lineno + 5].
59+
*/
1260
post_context?: string[];
61+
62+
/**
63+
* Signals whether this frame is related to the execution of the relevant code in this stack trace.
64+
* For example, the frames that might power the framework’s web server of your app are probably not relevant.
65+
* However, calls to the framework’s library once you start handling code likely are relevant.
66+
*/
1367
in_app?: boolean;
68+
69+
/**
70+
* A mapping of variables which were available within this frame (usually context-locals).
71+
*/
72+
vars?: Record<string, unknown>;
73+
74+
/**
75+
* An instruction address for symbolication.
76+
* This should be a string with a hexadecimal number that includes a 0x prefix.
77+
* If this is set and a known image is defined in the Debug Meta Interface,
78+
* then symbolication can take place.
79+
* Note that the addr_mode attribute can control the behavior of this address.
80+
*/
1481
instruction_addr?: string;
82+
83+
/**
84+
* Optionally changes the addressing mode.
85+
* The default value is the same as "abs" which means absolute referencing.
86+
* This can also be set to "rel:DEBUG_ID" or "rel:IMAGE_INDEX" to make addresses relative to an object referenced by debug id or index.
87+
* This for instance is necessary for WASM processing as WASM does not use a unified address space.
88+
*/
1589
addr_mode?: string;
16-
vars?: { [key: string]: any };
90+
91+
/**
92+
* An address that points to a symbol.
93+
* We use the instruction address for symbolication,
94+
* but this can be used to calculate an instruction offset automatically.
95+
* Note that the addr_mode attribute can control the behavior of this address.
96+
*/
97+
symbol_addr?: string;
98+
99+
/**
100+
* An address of the debug image to reference.
101+
*/
102+
image_addr?: string;
103+
104+
/**
105+
* The "package" the frame was contained in.
106+
* Depending on the platform, this can be different things.
107+
*/
108+
package?: string;
109+
110+
/**
111+
* This can override the platform for a single frame.
112+
* Otherwise, the platform of the event is assumed.
113+
* This can be used for multi-platform stack traces, such as in React Native.
114+
*/
115+
platform?: string;
17116
}

packages/types/src/stacktrace.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
import { StackFrame } from './stackframe';
22

3-
/** JSDoc */
3+
/**
4+
* A stack trace contains a list of frames,
5+
* each with various bits (most optional) describing the context of that frame.
6+
* Frames should be sorted from oldest to newest.
7+
* @external https://develop.sentry.dev/sdk/event-payloads/stacktrace/
8+
*/
49
export interface Stacktrace {
10+
/**
11+
* A non-empty list of stack frames.
12+
* The list is ordered from caller to callee, or oldest to youngest.
13+
* The last frame is the one creating the exception.
14+
*/
515
frames?: StackFrame[];
16+
17+
/**
18+
* A map of register names and their values.
19+
* The values should contain the actual register values of the thread,
20+
* thus mapping to the last frame in the list.
21+
*/
22+
registers?: Record<string, unknown>;
23+
624
frames_omitted?: [number, number];
725
}

packages/types/src/thread.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
import { Stacktrace } from './stacktrace';
22

3-
/** JSDoc */
3+
/**
4+
* The Threads Interface specifies threads that were running at the time an event happened.
5+
* These threads can also contain stack traces.
6+
* @external https://develop.sentry.dev/sdk/event-payloads/threads/
7+
*/
48
export interface Thread {
9+
/**
10+
* The ID of the thread.
11+
* Typically a number or numeric string.
12+
* Needs to be unique among the threads.
13+
* An exception can set the thread_id attribute to cross-reference this thread.
14+
*/
515
id?: number;
6-
name?: string;
7-
stacktrace?: Stacktrace;
16+
17+
/**
18+
* A flag indicating whether the thread crashed. Defaults to false.
19+
*/
820
crashed?: boolean;
21+
22+
/**
23+
* A flag indicating whether the thread was in the foreground.
24+
*/
925
current?: boolean;
26+
27+
/**
28+
* The thread name.
29+
*/
30+
name?: string;
31+
32+
/**
33+
* A stack trace object corresponding to the Stack Trace Interface.
34+
*/
35+
stacktrace?: Stacktrace;
1036
}

0 commit comments

Comments
 (0)