@@ -593,7 +593,8 @@ def parse_log_for_error(txt, regExp=None, stdout=True, msg=None):
593593
594594def extract_errors_from_log (log_txt , reg_exps ):
595595 """
596- Check log_txt for messages matching regExps and return warnings and errors
596+ Check provided string (command output) for messages matching specified regular expressions,
597+ and return 2-tuple with list of warnings and errors.
597598 :param log_txt: String containing the log, will be split into individual lines
598599 :param reg_exps: List of: regular expressions (as strings) to error on,
599600 or tuple of regular expression and action (any of [IGNORE, WARN, ERROR])
@@ -609,16 +610,21 @@ def extract_errors_from_log(log_txt, reg_exps):
609610 for cur in reg_exps :
610611 try :
611612 if isinstance (cur , str ):
613+ # use ERROR as default action if only regexp pattern is specified
612614 reg_exp , action = cur , ERROR
613- else :
615+ elif isinstance ( cur , tuple ) and len ( cur ) == 2 :
614616 reg_exp , action = cur
617+ else :
618+ raise TypeError ("Incorrect type of value, expected string or 2-tuple" )
619+
615620 if not isinstance (reg_exp , str ):
616- raise TypeError ("RegExp must be passed as string" )
621+ raise TypeError ("Regular expressions must be passed as string, got %s" % type ( reg_exp ) )
617622 if action not in actions :
618- raise TypeError ("action must be one of %s" % action )
623+ raise TypeError ("action must be one of %s, got %s" % (actions , action ))
624+
619625 re_tuples .append ((re .compile (reg_exp ), action ))
620- except Exception as e :
621- raise EasyBuildError ("Invalid input: No RegExp or tuple of RegExp and action '%s' (%s) " , str (cur ), e )
626+ except Exception as err :
627+ raise EasyBuildError ("Invalid input: No regexp or tuple of regexp and action '%s': %s " , str (cur ), err )
622628
623629 warnings = []
624630 errors = []
0 commit comments