1- import { Event } from '@sentry/types' ;
1+ import { Event , EventHint , Options , Severity } from '@sentry/types' ;
22import {
33 addExceptionMechanism ,
44 addExceptionTypeValue ,
@@ -8,12 +8,56 @@ import {
88 isErrorEvent ,
99 isEvent ,
1010 isPlainObject ,
11+ SyncPromise ,
1112} from '@sentry/utils' ;
1213
1314import { eventFromPlainObject , eventFromStacktrace , prepareFramesForEvent } from './parsers' ;
1415import { computeStackTrace } from './tracekit' ;
1516
16- /** JSDoc */
17+ /**
18+ * Builds and Event from a Exception
19+ * @hidden
20+ */
21+ export function eventFromException ( options : Options , exception : any , hint ?: EventHint ) : PromiseLike < Event > {
22+ const syntheticException = ( hint && hint . syntheticException ) || undefined ;
23+ const event = eventFromUnknownInput ( exception , syntheticException , {
24+ attachStacktrace : options . attachStacktrace ,
25+ } ) ;
26+ addExceptionMechanism ( event , {
27+ handled : true ,
28+ type : 'generic' ,
29+ } ) ;
30+ event . level = Severity . Error ;
31+ if ( hint && hint . event_id ) {
32+ event . event_id = hint . event_id ;
33+ }
34+ return SyncPromise . resolve ( event ) ;
35+ }
36+
37+ /**
38+ * Builds and Event from a Message
39+ * @hidden
40+ */
41+ export function eventFromMessage (
42+ options : Options ,
43+ message : string ,
44+ level : Severity = Severity . Info ,
45+ hint ?: EventHint ,
46+ ) : PromiseLike < Event > {
47+ const syntheticException = ( hint && hint . syntheticException ) || undefined ;
48+ const event = eventFromString ( message , syntheticException , {
49+ attachStacktrace : options . attachStacktrace ,
50+ } ) ;
51+ event . level = level ;
52+ if ( hint && hint . event_id ) {
53+ event . event_id = hint . event_id ;
54+ }
55+ return SyncPromise . resolve ( event ) ;
56+ }
57+
58+ /**
59+ * @hidden
60+ */
1761export function eventFromUnknownInput (
1862 exception : unknown ,
1963 syntheticException ?: Error ,
@@ -79,8 +123,9 @@ export function eventFromUnknownInput(
79123 return event ;
80124}
81125
82- // this._options.attachStacktrace
83- /** JSDoc */
126+ /**
127+ * @hidden
128+ */
84129export function eventFromString (
85130 input : string ,
86131 syntheticException ?: Error ,
0 commit comments