Fix error handling.

Until now, all error messages were set to "Unknown error".