Logging database exception in controller