rticommunity / rticonnextdds-connector-go

RTI Connector for Connext DDS is a lightweight technology that enables DDS data to be accessed with Go.
Other
26 stars 12 forks source link

Add error types #46

Closed tom-wp closed 2 years ago

tom-wp commented 2 years ago

Changes

Reason

In calling code it is often needed to handle timeouts and no-data errors differently to other core errors as these errors can occur as part of a normal connection process.

Testing the error string in the calling code relies on internal knowledge of the library and could be broken by a future update. Exporting the error types allows the error text to change in the future. It also makes testing for the error simple, for example:

import (
    rti "github.com/rticommunity/rticonnextdds-connector-go"
)

...

if errors.Is(err, rti.ErrNoData) {
  // Handle no data
}

This change also corrects a typo in one error string "Exceptrion" which could make it a breaking change if anyone currently relies on string matching.

This change was authored by my colleague @mwak2 who is no longer with the company.