@@ -90,7 +90,7 @@ def scan_repository(context: click.Context, path: str, branch: str) -> None:
9090        perform_pre_scan_documents_actions (context , scan_type , documents_to_scan , is_git_diff = False )
9191
9292        logger .debug ('Found all relevant files for scanning %s' , {'path' : path , 'branch' : branch })
93-         return   scan_documents (
93+         scan_documents (
9494            context , documents_to_scan , is_git_diff = False , scan_parameters = get_scan_parameters (context , path )
9595        )
9696    except  Exception  as  e :
@@ -420,6 +420,16 @@ def scan_documents(
420420) ->  None :
421421    progress_bar  =  context .obj ['progress_bar' ]
422422
423+     if  not  documents_to_scan :
424+         progress_bar .stop ()
425+         ConsolePrinter (context ).print_error (
426+             CliError (
427+                 code = 'no_relevant_files' ,
428+                 message = 'Error: The scan could not be completed - relevant files to scan are not found.' ,
429+             )
430+         )
431+         return 
432+ 
423433    scan_batch_thread_func  =  _get_scan_documents_thread_func (context , is_git_diff , is_commit_range , scan_parameters )
424434    errors , local_scan_results  =  run_parallel_batched_scan (
425435        scan_batch_thread_func , documents_to_scan , progress_bar = progress_bar 
@@ -430,25 +440,7 @@ def scan_documents(
430440    progress_bar .stop ()
431441
432442    set_issue_detected_by_scan_results (context , local_scan_results )
433-     print_results (context , local_scan_results )
434- 
435-     if  not  errors :
436-         return 
437- 
438-     if  context .obj ['output' ] ==  'json' :
439-         # TODO(MarshalX): we can't just print JSON formatted errors here 
440-         #  because we should return only one root json structure per scan 
441-         #  could be added later to "print_results" function if we wish to display detailed errors in UI 
442-         return 
443- 
444-     click .secho (
445-         'Unfortunately, Cycode was unable to complete the full scan. ' 
446-         'Please note that not all results may be available:' ,
447-         fg = 'red' ,
448-     )
449-     for  scan_id , error  in  errors .items ():
450-         click .echo (f'- { scan_id }  , nl = False )
451-         ConsolePrinter (context ).print_error (error )
443+     print_results (context , local_scan_results , errors )
452444
453445
454446def  scan_commit_range_documents (
@@ -506,6 +498,7 @@ def scan_commit_range_documents(
506498        progress_bar .update (ProgressBarSection .GENERATE_REPORT )
507499        progress_bar .stop ()
508500
501+         # errors will be handled with try-except block; printing will not occur on errors 
509502        print_results (context , [local_scan_result ])
510503
511504        scan_completed  =  True 
@@ -693,9 +686,11 @@ def print_debug_scan_details(scan_details_response: 'ScanDetailsResponse') -> No
693686        logger .debug (f'Scan message: { scan_details_response .message }  )
694687
695688
696- def  print_results (context : click .Context , local_scan_results : List [LocalScanResult ]) ->  None :
689+ def  print_results (
690+     context : click .Context , local_scan_results : List [LocalScanResult ], errors : Optional [Dict [str , 'CliError' ]] =  None 
691+ ) ->  None :
697692    printer  =  ConsolePrinter (context )
698-     printer .print_scan_results (local_scan_results )
693+     printer .print_scan_results (local_scan_results ,  errors )
699694
700695
701696def  get_document_detections (
0 commit comments