<s> """<STR_LIT>""" <EOL> try : <EOL> unicode <EOL> except NameError : <EOL> unicode = str <EOL> INFO_PRINTED = <NUM_LIT> <EOL> DATA_ERROR = <NUM_LIT> <EOL> STOPPED_BY_USER = <NUM_LIT> <EOL> FRAMEWORK_ERROR = <NUM_LIT:255> <EOL> class RobotError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message = '<STR_LIT>' , details = '<STR_LIT>' ) : <EOL> Exception . __init__ ( self , message ) <EOL> self . details = details <EOL> @ property <EOL> def message ( self ) : <EOL> return unicode ( self ) <EOL> class FrameworkError ( RobotError ) : <EOL> """<STR_LIT>""" <EOL> class DataError ( RobotError ) : <EOL> """<STR_LIT>""" <EOL> class VariableError ( DataError ) : <EOL> """<STR_LIT>""" <EOL> class TimeoutError ( RobotError ) : <EOL> """<STR_LIT>""" <EOL> class Information ( RobotError ) : <EOL> """<STR_LIT>""" <EOL> class ExecutionFailed ( RobotError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message , timeout = False , syntax = False , exit = False , <EOL> continue_on_failure = False , return_value = None ) : <EOL> if '<STR_LIT:\r\n>' in message : <EOL> message = message . replace ( '<STR_LIT:\r\n>' , '<STR_LIT:\n>' ) <EOL> from robot . utils import cut_long_message <EOL> RobotError . __init__ ( self , cut_long_message ( message ) ) <EOL> self . timeout = timeout <EOL> self . syntax = syntax <EOL> self . exit = exit <EOL> self . _continue_on_failure = continue_on_failure <EOL> self . return_value = return_value <EOL> @ property <EOL> def dont_continue ( self ) : <EOL> return self . timeout or self . syntax or self . exit <EOL> @ property <EOL> def continue_on_failure ( self ) : <EOL> return self . _continue_on_failure <EOL> @ continue_on_failure . setter <EOL> def continue_on_failure ( self , continue_on_failure ) : <EOL> self . _continue_on_failure = continue_on_failure <EOL> for child in getattr ( self , '<STR_LIT>' , [ ] ) : <EOL> child . continue_on_failure = continue_on_failure <EOL> def can_continue ( self , teardown = False , templated = False , dry_run = False ) : <EOL> if dry_run : <EOL> return True <EOL> if self . dont_continue and not ( teardown and self . syntax ) : <EOL> return False <EOL> if teardown or templated : <EOL> return True <EOL> return self . continue_on_failure <EOL> def get_errors ( self ) : <EOL> return [ self ] <EOL> @ property <EOL> def status ( self ) : <EOL> return '<STR_LIT>' <EOL> class HandlerExecutionFailed ( ExecutionFailed ) : <EOL> def __init__ ( self , details ) : <EOL> timeout = isinstance ( details . error , TimeoutError ) <EOL> syntax = isinstance ( details . error , DataError ) and not isinstance ( details . error , VariableError ) <EOL> exit_on_failure = self . _get ( details . error , '<STR_LIT>' ) <EOL> continue_on_failure = self . _get ( details . error , '<STR_LIT>' ) <EOL> ExecutionFailed . __init__ ( self , details . message , timeout , syntax , <EOL> exit_on_failure , continue_on_failure ) <EOL> self . full_message = details . message <EOL> self . traceback = details . traceback <EOL> def _get ( self , error , attr ) : <EOL> return bool ( getattr ( error , '<STR_LIT>' + attr , False ) ) <EOL> class ExecutionFailures ( ExecutionFailed ) : <EOL> def __init__ ( self , errors , message = None ) : <EOL> message = message or self . _format_message ( [ e . message for e in errors ] ) <EOL> ExecutionFailed . __init__ ( self , message , ** self . _get_attrs ( errors ) ) <EOL> self . _errors = errors <EOL> def _format_message ( self , messages ) : <EOL> if len ( messages ) == <NUM_LIT:1> : <EOL> return messages [ <NUM_LIT:0> ] <EOL> lines = [ '<STR_LIT>' ] + [ '<STR_LIT>' % ( i + <NUM_LIT:1> , m ) for i , m in enumerate ( messages ) ] <EOL> return '<STR_LIT>' . join ( lines ) <EOL> def _get_attrs ( self , errors ) : <EOL> return { '<STR_LIT>' : any ( err . timeout for err in errors ) , <EOL> '<STR_LIT>' : any ( err . syntax for err in errors ) , <EOL> '<STR_LIT>' : any ( err . exit for err in errors ) , <EOL> '<STR_LIT>' : all ( err . continue_on_failure for err in errors ) <EOL> } <EOL> def get_errors ( self ) : <EOL> return self . _errors <EOL> class UserKeywordExecutionFailed ( ExecutionFailures ) : <EOL> def __init__ ( self , run_errors = None , teardown_errors = None ) : <EOL> errors = self . _get_active_errors ( run_errors , teardown_errors ) <EOL> message = self . _get_message ( run_errors , teardown_errors ) <EOL> ExecutionFailures . __init__ ( self , errors , message ) <EOL> if run_errors and not teardown_errors : <EOL> self . _errors = run_errors . get_errors ( ) <EOL> else : <EOL> self . _errors = [ self ] <EOL> def _get_active_errors ( self , * errors ) : <EOL> return [ err for err in errors if err ] <EOL> def _get_message ( self , run_errors , teardown_errors ) : <EOL> run_msg = run_errors . message if run_errors else '<STR_LIT>' <EOL> td_msg = teardown_errors . message if teardown_errors else '<STR_LIT>' <EOL> if not td_msg : <EOL> return run_msg <EOL> if not run_msg : <EOL> return '<STR_LIT>' % td_msg <EOL> return '<STR_LIT>' % ( run_msg , td_msg ) <EOL> class ExecutionPassed ( ExecutionFailed ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message = None , ** kwargs ) : <EOL> ExecutionFailed . __init__ ( self , message or self . _get_message ( ) , ** kwargs ) <EOL> self . _earlier_failures = [ ] <EOL> def _get_message ( self ) : <EOL> from robot . utils import printable_name <EOL> return "<STR_LIT>" % printable_name ( self . __class__ . __name__ , code_style = True ) <EOL> def set_earlier_failures ( self , failures ) : <EOL> if failures : <EOL> self . _earlier_failures . extend ( failures ) <EOL> @ property <EOL> def earlier_failures ( self ) : <EOL> if not self . _earlier_failures : <EOL> return None <EOL> return ExecutionFailures ( self . _earlier_failures ) <EOL> @ property <EOL> def status ( self ) : <EOL> return '<STR_LIT>' if not self . _earlier_failures else '<STR_LIT>' <EOL> class PassExecution ( ExecutionPassed ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message ) : <EOL> ExecutionPassed . __init__ ( self , message ) <EOL> class ContinueForLoop ( ExecutionPassed ) : <EOL> """<STR_LIT>""" <EOL> class ExitForLoop ( ExecutionPassed ) : <EOL> """<STR_LIT>""" <EOL> class ReturnFromKeyword ( ExecutionPassed ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , return_value ) : <EOL> ExecutionPassed . __init__ ( self , return_value = return_value ) <EOL> class RemoteError ( RobotError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message = '<STR_LIT>' , details = '<STR_LIT>' , fatal = False , continuable = False ) : <EOL> RobotError . __init__ ( self , message , details ) <EOL> self . ROBOT_EXIT_ON_FAILURE = fatal <EOL> self . ROBOT_CONTINUE_ON_FAILURE = continuable </s>
