@@ -64,7 +64,7 @@ pub enum UnhandledError {
6464// NOTE - these are serialized and deserialized, so that when we fail to get a symbol set from
6565// some provider (e.g. we fail to look up a sourcemap), we can return the correct error in the future
6666// without hitting their infra again (by storing it in PG).
67- #[ derive( Debug , Error , Serialize , Deserialize ) ]
67+ #[ derive( Debug , Clone , PartialEq , Eq , Error , Serialize , Deserialize ) ]
6868pub enum FrameError {
6969 #[ error( transparent) ]
7070 JavaScript ( #[ from] JsResolveErr ) ,
@@ -78,7 +78,7 @@ pub enum FrameError {
7878 MissingChunkIdData ( String ) ,
7979}
8080
81- #[ derive( Debug , Error , Serialize , Deserialize ) ]
81+ #[ derive( Debug , Clone , PartialEq , Eq , Error , Serialize , Deserialize ) ]
8282pub enum JsResolveErr {
8383 #[ error( "This frame had no source url or chunk id" ) ]
8484 NoUrlOrChunkId ,
@@ -130,7 +130,7 @@ pub enum JsResolveErr {
130130 NoSourcemapUploaded ( String ) ,
131131}
132132
133- #[ derive( Debug , Error , Serialize , Deserialize ) ]
133+ #[ derive( Debug , Clone , PartialEq , Eq , Error , Serialize , Deserialize ) ]
134134pub enum HermesError {
135135 #[ error( "Data error: {0}" ) ]
136136 DataError ( #[ from] SymbolDataError ) ,
@@ -144,7 +144,7 @@ pub enum HermesError {
144144 NoTokenForColumn ( u32 , String ) ,
145145}
146146
147- #[ derive( Debug , Error , Serialize , Deserialize ) ]
147+ #[ derive( Debug , Clone , PartialEq , Eq , Error , Serialize , Deserialize ) ]
148148pub enum ProguardError {
149149 #[ error( "Data error: {0}" ) ]
150150 DataError ( #[ from] SymbolDataError ) ,
@@ -164,7 +164,7 @@ pub enum ProguardError {
164164 InvalidClass ,
165165}
166166
167- #[ derive( Debug , Error , Serialize , Deserialize ) ]
167+ #[ derive( Debug , Clone , PartialEq , Eq , Error , Serialize , Deserialize ) ]
168168pub enum AppleError {
169169 #[ error( "Data error: {0}" ) ]
170170 DataError ( #[ from] SymbolDataError ) ,
@@ -206,6 +206,72 @@ pub enum EventError {
206206 FilteredByTeamId ,
207207}
208208
209+ impl JsResolveErr {
210+ pub fn metric_reason ( & self ) -> & ' static str {
211+ match self {
212+ Self :: NoUrlOrChunkId | Self :: NoSourceUrl => "no_reference" ,
213+ Self :: NoSourcemap ( _) | Self :: NoSourcemapUploaded ( _) => "no_symbol_set" ,
214+ Self :: TokenNotFound ( ..) => "symbol_not_found" ,
215+ Self :: Timeout ( _)
216+ | Self :: HttpStatus ( ..)
217+ | Self :: NetworkError ( _)
218+ | Self :: RedirectError ( _) => "network_error" ,
219+ Self :: InvalidSourceMap ( _)
220+ | Self :: InvalidSourceUrl ( _)
221+ | Self :: InvalidSourceMapHeader ( _)
222+ | Self :: InvalidSourceMapUrl ( _)
223+ | Self :: InvalidDataUrl ( ..)
224+ | Self :: JSDataError ( _)
225+ | Self :: InvalidSourceAndMap => "invalid_data" ,
226+ }
227+ }
228+ }
229+
230+ impl HermesError {
231+ pub fn metric_reason ( & self ) -> & ' static str {
232+ match self {
233+ Self :: NoChunkId => "no_reference" ,
234+ Self :: NoSourcemapUploaded ( _) => "no_symbol_set" ,
235+ Self :: NoTokenForColumn ( ..) => "symbol_not_found" ,
236+ Self :: DataError ( _) | Self :: InvalidMap ( _) => "invalid_data" ,
237+ }
238+ }
239+ }
240+
241+ impl ProguardError {
242+ pub fn metric_reason ( & self ) -> & ' static str {
243+ match self {
244+ Self :: NoMapId | Self :: NoModuleProvided => "no_reference" ,
245+ Self :: MissingMap ( _) => "no_symbol_set" ,
246+ Self :: NoOriginalFrames | Self :: MissingClass => "symbol_not_found" ,
247+ Self :: DataError ( _) | Self :: InvalidMapping | Self :: InvalidClass => "invalid_data" ,
248+ }
249+ }
250+ }
251+
252+ impl AppleError {
253+ pub fn metric_reason ( & self ) -> & ' static str {
254+ match self {
255+ Self :: NoDebugId | Self :: NoMatchingDebugImage => "no_reference" ,
256+ Self :: MissingDsym ( _) => "no_symbol_set" ,
257+ Self :: SymbolNotFound ( _) => "symbol_not_found" ,
258+ Self :: DataError ( _) | Self :: InvalidAddress ( _) | Self :: ParseError ( _) => "invalid_data" ,
259+ }
260+ }
261+ }
262+
263+ impl FrameError {
264+ pub fn metric_reason ( & self ) -> & ' static str {
265+ match self {
266+ Self :: JavaScript ( e) => e. metric_reason ( ) ,
267+ Self :: Hermes ( e) => e. metric_reason ( ) ,
268+ Self :: Proguard ( e) => e. metric_reason ( ) ,
269+ Self :: Apple ( e) => e. metric_reason ( ) ,
270+ Self :: MissingChunkIdData ( _) => "no_symbol_set" ,
271+ }
272+ }
273+ }
274+
209275impl From < JsResolveErr > for ResolveError {
210276 fn from ( e : JsResolveErr ) -> Self {
211277 FrameError :: JavaScript ( e) . into ( )
0 commit comments