change error message to Error object