1212from py42 .sdk .file_event_query .file_query import MD5 , SHA256 , FileName , FilePath
1313
1414from code42cli .compat import str
15- from code42cli .util import print_error , print_bold
15+ from code42cli .util import print_error , print_bold , is_interactive
1616from code42cli .profile .profile import get_profile
1717from code42cli .securitydata .options import ExposureType as ExposureTypeOptions
1818from code42cli .securitydata import date_helper as date_helper
2222from code42cli .securitydata .arguments .main import IS_INCREMENTAL_KEY
2323
2424
25+ _EXCEPTIONS_OCCURRED = False
26+
27+
2528def extract (output_logger , args ):
2629 """Extracts file events using the given command-line arguments.
2730
@@ -38,12 +41,20 @@ def extract(output_logger, args):
3841 sdk = _get_sdk (profile , args .is_debug_mode )
3942 extractor = FileEventExtractor (sdk , handlers )
4043 _call_extract (extractor , args )
44+ _handle_result ()
4145
4246
4347def _create_event_handlers (output_logger , is_incremental ):
4448 handlers = FileEventHandlers ()
4549 error_logger = get_error_logger ()
46- handlers .handle_error = error_logger .error
50+
51+ def handle_error (exception ):
52+ error_logger .error (exception )
53+ global _EXCEPTIONS_OCCURRED
54+ _EXCEPTIONS_OCCURRED = True
55+
56+ handlers .handle_error = handle_error
57+
4758 if is_incremental :
4859 store = AEDCursorStore ()
4960 handlers .record_cursor_position = store .replace_stored_insertion_timestamp
@@ -116,7 +127,7 @@ def _verify_begin_date(begin_date):
116127 if not begin_date :
117128 print_error (u"'begin date' is required." )
118129 print (u"" )
119- print (u"Try using '-b' or '--begin'. Use `-h` for more info." )
130+ print_bold (u"Try using '-b' or '--begin'. Use `-h` for more info." )
120131 print (u"" )
121132 exit (1 )
122133
@@ -131,6 +142,11 @@ def _verify_exposure_types(exposure_types):
131142 exit (1 )
132143
133144
145+ def _handle_result ():
146+ if is_interactive () and _EXCEPTIONS_OCCURRED :
147+ print_error (u"View exceptions that occurred at [HOME]/.code42cli/log/code42_errors." )
148+
149+
134150def _create_filters (args ):
135151 filters = [_get_event_timestamp_filter (args )]
136152 not args .c42username or filters .append (DeviceUsername .eq (args .c42username ))
0 commit comments