Exception handling and logging implementation.