Class-based error handling