Fixed encoding problem in error handling