Initial error refactoring (make errors less HTTP specific)