docs: def pdu_to_function_code_or_raise_error(resp_pdu):
      """ Parse response PDU and return of :class:`ModbusFunction` or
      raise error.
  
      :param resp_pdu: PDU of response.
      :return: Subclass of :class:`ModbusFunction` matching the response.
      :raises ModbusError: When response contains error code.
      """
      function_code = struct.unpack('>B', resp_pdu[0:1])[0]
  
      if function_code not in function_code_to_function_map.keys():
          error_code = struct.unpack('>B', resp_pdu[1:2])[0]
          raise error_code_to_exception_map[error_code]
  
      return function_code