src.fairreckitlib.core.events.event_error
This module contains all event ids, event args and a print switch that are error related.
Constants:
ON_FAILURE_ERROR: id of the event that is used when a failure occurs.
ON_RAISE_ERROR: id of the event that is used when an error was raised.
Classes:
ErrorEventArgs: event args for errors.
Functions:
get_error_events: list of error event IDs.
get_error_event_print_switch: switch to print error event arguments by ID.
This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences)
1"""This module contains all event ids, event args and a print switch that are error related. 2 3Constants: 4 5 ON_FAILURE_ERROR: id of the event that is used when a failure occurs. 6 ON_RAISE_ERROR: id of the event that is used when an error was raised. 7 8Classes: 9 10 ErrorEventArgs: event args for errors. 11 12Functions: 13 14 get_error_events: list of error event IDs. 15 get_error_event_print_switch: switch to print error event arguments by ID. 16 17This program has been developed by students from the bachelor Computer Science at 18Utrecht University within the Software Project course. 19© Copyright Utrecht University (Department of Information and Computing Sciences) 20""" 21 22from dataclasses import dataclass 23from typing import Callable, Dict, List 24 25from .event_args import EventArgs, MessageEventArgs 26 27ON_FAILURE_ERROR = 'Error.on_failure' 28ON_RAISE_ERROR = 'Error.on_raise' 29 30 31@dataclass 32class ErrorEventArgs(MessageEventArgs): 33 """Error Event Arguments. 34 35 event_id: the unique ID that classifies the error event. 36 message: the error message. 37 """ 38 39 40def get_error_events() -> List[str]: 41 """Get a list of error event IDs. 42 43 Returns: 44 a list of unique error event IDs. 45 """ 46 return [ 47 # ErrorEventArgs 48 ON_FAILURE_ERROR, 49 ON_RAISE_ERROR 50 ] 51 52 53def get_error_event_print_switch() -> Dict[str, Callable[[EventArgs], None]]: 54 """Get a switch that prints error event IDs. 55 56 Returns: 57 the print error event switch. 58 """ 59 print_error = lambda args: print(args.message) 60 return { 61 ON_FAILURE_ERROR: print_error, 62 ON_RAISE_ERROR: print_error, 63 }
32@dataclass 33class ErrorEventArgs(MessageEventArgs): 34 """Error Event Arguments. 35 36 event_id: the unique ID that classifies the error event. 37 message: the error message. 38 """
Error Event Arguments.
event_id: the unique ID that classifies the error event. message: the error message.
def
get_error_events() -> List[str]:
41def get_error_events() -> List[str]: 42 """Get a list of error event IDs. 43 44 Returns: 45 a list of unique error event IDs. 46 """ 47 return [ 48 # ErrorEventArgs 49 ON_FAILURE_ERROR, 50 ON_RAISE_ERROR 51 ]
Get a list of error event IDs.
Returns: a list of unique error event IDs.
def
get_error_event_print_switch() -> Dict[str, Callable[[src.fairreckitlib.core.events.event_args.EventArgs], NoneType]]:
54def get_error_event_print_switch() -> Dict[str, Callable[[EventArgs], None]]: 55 """Get a switch that prints error event IDs. 56 57 Returns: 58 the print error event switch. 59 """ 60 print_error = lambda args: print(args.message) 61 return { 62 ON_FAILURE_ERROR: print_error, 63 ON_RAISE_ERROR: print_error, 64 }
Get a switch that prints error event IDs.
Returns: the print error event switch.