@@ -930,25 +930,32 @@ internal void HandleLowMemory()
930930 /// <param name="type">log type</param>
931931 internal void HandleUnityMessage ( string message , string stackTrace , LogType type )
932932 {
933- if ( ! Enabled )
933+ if ( ! Enabled || ! Configuration . HandleUnhandledExceptions )
934934 {
935935 return ;
936936 }
937- var unityMessage = new BacktraceUnityMessage ( message , stackTrace , type ) ;
938- if ( Configuration . HandleUnhandledExceptions && unityMessage . IsUnhandledException ( ) )
937+ if ( string . IsNullOrEmpty ( message ) || ( type != LogType . Error && type != LogType . Exception ) )
939938 {
940- BacktraceUnhandledException exception = null ;
941- var invokeSkipApi = true ;
942-
943- // detect sampling flow
944- // we should apply sampling only to unhandled exceptions that are type LogType == Error
945- // log type error won't provide full exception information
946- if ( type == LogType . Error && SamplingShouldSkip ( ) )
939+ return ;
940+ }
941+ BacktraceUnhandledException exception = null ;
942+ var invokeSkipApi = true ;
943+ // detect sampling flow for LogType.Error + filter LogType.Error if client prefer to ignore them.
944+ if ( type == LogType . Error )
945+ {
946+ if ( Configuration . ReportFilterType . HasFlag ( ReportFilterType . Error ) )
947+ {
948+ return ;
949+ }
950+ if ( SamplingShouldSkip ( ) )
947951 {
948- if ( SkipReport != null || Configuration . ReportFilterType . HasFlag ( ReportFilterType . UnhandledException ) )
952+ if ( SkipReport != null )
949953 {
950- exception = new BacktraceUnhandledException ( unityMessage . Message , unityMessage . StackTrace ) ;
951- if ( ShouldSkipReport ( ReportFilterType . UnhandledException , exception , string . Empty ) )
954+ exception = new BacktraceUnhandledException ( message , stackTrace )
955+ {
956+ Type = type
957+ } ;
958+ if ( ShouldSkipReport ( ReportFilterType . Error , exception , string . Empty ) )
952959 {
953960 return ;
954961 }
@@ -959,14 +966,17 @@ internal void HandleUnityMessage(string message, string stackTrace, LogType type
959966 return ;
960967 }
961968 }
969+ }
962970
963- if ( exception == null )
971+ if ( exception == null )
972+ {
973+ exception = new BacktraceUnhandledException ( message , stackTrace )
964974 {
965- exception = new BacktraceUnhandledException ( unityMessage . Message , unityMessage . StackTrace ) ;
966- }
967-
968- SendUnhandledException ( exception , invokeSkipApi ) ;
975+ Type = type
976+ } ;
969977 }
978+
979+ SendUnhandledException ( exception , invokeSkipApi ) ;
970980 }
971981
972982 /// <summary>
@@ -1010,9 +1020,10 @@ private bool ShouldSendReport(Exception exception, List<string> attachmentPaths,
10101020 var filterType = ReportFilterType . Exception ;
10111021 if ( exception is BacktraceUnhandledException )
10121022 {
1013- filterType = ( exception as BacktraceUnhandledException ) . Classifier == "ANRException"
1023+ var unhandledException = ( exception as BacktraceUnhandledException ) ;
1024+ filterType = unhandledException . Classifier == "ANRException"
10141025 ? ReportFilterType . Hang
1015- : ReportFilterType . UnhandledException ;
1026+ : unhandledException . Type == LogType . Exception ? ReportFilterType . UnhandledException : ReportFilterType . Error ;
10161027 }
10171028
10181029
0 commit comments