checkResponse method

dynamic checkResponse(
  1. ReadBuffer 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(ReadBuffer response, [bool prepareStmt = false, bool isHandlingRows = false]) {
  if (response[0] == PACKET_OK && !isHandlingRows) {
    if (prepareStmt) {
      var okPacket = PrepareOkPacket.fromBuffer(response);
      return okPacket;
    } else {
      var okPacket = OkPacket.fromBuffer(response);
      return okPacket;
    }
  } else if (response[0] == PACKET_ERROR) {
    //throw MySqlException(response);
    throw createMySqlException(response);
  }

  return null;
}