add error doc and modify NewError to return reference