handle error in serve