handleError now returns the message instead of the type for custom errors