cleaned up error handling of different loglevels

Cleaned up the error handling