refactor with http-errors

cc @eivindfjeldstad @jonathanong 
breaking change here