Error handling/Inter-class communication

Table of Contents

Error checking is the responsibility of the end class consumer. This, of course, has its drawbacks, but should prove sufficient if careful. The mechanism is in place through low level C functions to signal an error has occurred; simply use the system_log function. For example, to handle SCI errors simply use the following mechanism:

  ...
  clear_log();
  while (c != '@')
  {
    while (!oSCI::havebyte()) CHECK
    c = oSCI::inbyte();
    if (system_status())
    {
      green.off();
      red.on();
      break;
    }
    temp[bytes++] = c;
  }

  if (system_status())
  {
    switch (system_status())
    {
    case SCI_RX_OVERFLOW:
      MOS::beep(1);
      return;
      break;
    case SCI_PF_ERROR:
      MOS::beep(2);
      return;
      break;
    case SCI_FE_ERROR:
      MOS::beep(3);
      return;
      break;
    case SCI_NF_ERROR:
      MOS::beep(4);
      return;
      break;
    case SCI_OR_ERROR:
      MOS::beep(5);
      return;
      break;
    case SCI_IDLE_ERROR:
      MOS::beep(6);
      return;
      break;
    default:
      return;
      break;
    }

The message numbers should be standardized numbers across all systems. Thus you can do specific handling based upon the error returned. Also, there is a primitive error level. Refer to status