Reject the promise on buildDoc error
Update resolve error handing for HTTP errors