[api] start to move some exceptions to a central place