Error Handling
 

Because Delphi supports a powerful exception mechanism, hbTapi handles most errors as Delphi exceptions. Read the documentation of a function or property to be aware of possible occuring exceptions (errors).

Another error handling mechanism is used for exceptions catched during event calling und while updating TAPI data structured. In such case, first the ThbTapiApplication.OnError event is called, folowed by the ThbTapiLine.OnError resp. ThbTapiPhone.OnError event.

TAPI Errors

TAPI functions do return zero if the function succeeds or a negative error number defined by the LINEERR_ constants if an error occurs. Everytime a TAPI function called by hbTapi Components returns a negative error number, the error is indicated as a EhbTapiError exception.

Some TAPI functions work in an asynchronous manner. They return immediately with an error or positive result - the request id. The real result of the function is then returned later within a TAPI reply message. When you're using hbTapi Components in an asynchronous manner, you have to use the LastRequestID property and the OnTapiReply event to get the result of an asynchronous function. Otherwise an error is immediately indicated as an exception.

Procedure TForm1.DropCall(Call: ThbTapiCall);
begin
  try
    Call.Drop;
  except
    on E:EhbTapiError do
    begin
      if E.ErrorCode = LINEERR_NOTOWNER then
      begin
        Call.PrivilegeOwner := True;
        Call.Drop;
      end
      else
        raise E;
    end;
  end;
end;

WAVE Errors

WAVE multimedia functions do return zero if the function succeeds or a value defined by the MMSYSERR_ constants if an error occurs. Everytime a wave function called by hbTapi Components returns an error number, the error is indicated as an EWaveError exception.

hbhbWaveOut1.Active := False;
hbhbWaveOut1.DeviceName := 'Wave Device #1';
hbhbWaveOut1.Playlist.Clear;
hbhbWaveOut1.Playlist.Add'('wavefile.wav');
try
  hbhbWaveOut1.Active := True;
except
  on E:EWaveError do
  begin
    if E.ErrorCode = MMSYSERR_ALLOCATED then
    begin
      MessageDlg('Specified resource is already allocated.', mtInformation, [mbOk], 0);
    end
    else
      raise E;
  end;
end;

See Also

ThbTapiApplication.OnError, ThbTapiLine.OnError , ThbTapiPhone.OnError