Add api error exception class

@mattlebel @liuhenry