checkResponse method

dynamic checkResponse(
  1. Buffer response, [
  2. bool prepareStmt = false,
  3. bool isHandlingRows = false
])

Parses the response packet to recognise Ok and Error packets. Returns an _OkPacket if the packet was an Ok packet, throws a MySqlException if it was an Error packet, or returns null if the packet has not been handled by this method.

Implementation

dynamic checkResponse(Buffer response,
    [bool prepareStmt = false, bool isHandlingRows = false]) {
  if (response[0] == PACKET_OK && !isHandlingRows) {
    if (prepareStmt) {
      var okPacket = PrepareOkPacket(response);
      log.fine(okPacket.toString());
      return okPacket;
    } else {
      var okPacket = OkPacket(response);
      log.fine(okPacket.toString());
      return okPacket;
    }
  } else if (response[0] == PACKET_ERROR) {
    throw createMySqlException(response);
  }
  return null;
}