Check returned data length and throw exceptions