add err handler in server API