@@ -376,13 +376,13 @@ def apply_jobs(self):
376376 continue
377377 if self .is_blacklisted (job .title , job .company , job .link , job .location ):
378378 logger .debug (f"Job blacklisted: { job .title } at { job .company } in { job .location } " )
379- self .write_to_file (job , "skipped" )
379+ self .write_to_file (job , "skipped" , "Job blacklisted" )
380380 continue
381381 if self .is_already_applied_to_job (job .title , job .company , job .link ):
382- self .write_to_file (job , "skipped" )
382+ self .write_to_file (job , "skipped" , "Already applied to this job" )
383383 continue
384384 if self .is_already_applied_to_company (job .company ):
385- self .write_to_file (job , "skipped" )
385+ self .write_to_file (job , "skipped" , "Already applied to this company" )
386386 continue
387387 try :
388388 if job .apply_method not in {"Continue" , "Applied" , "Apply" }:
@@ -391,10 +391,10 @@ def apply_jobs(self):
391391 logger .debug (f"Applied to job: { job .title } at { job .company } " )
392392 except Exception as e :
393393 logger .error (f"Failed to apply for { job .title } at { job .company } : { e } " )
394- self .write_to_file (job , "failed" )
394+ self .write_to_file (job , "failed" , f"Application error: { str ( e ) } " )
395395 continue
396396
397- def write_to_file (self , job , file_name ):
397+ def write_to_file (self , job , file_name , reason = None ):
398398 logger .debug (f"Writing job application result to file: { file_name } " )
399399 pdf_path = Path (job .pdf_path ).resolve ()
400400 pdf_path = pdf_path .as_uri ()
@@ -406,6 +406,10 @@ def write_to_file(self, job, file_name):
406406 "job_location" : job .location ,
407407 "pdf_path" : pdf_path
408408 }
409+
410+ if reason :
411+ data ["reason" ] = reason
412+
409413 file_path = self .output_file_directory / f"{ file_name } .json"
410414 if not file_path .exists ():
411415 with open (file_path , 'w' , encoding = 'utf-8' ) as f :
0 commit comments