Adding HTTP status 500 (internal service error) handling