refactor error to allow formatting