Skip to content

Setting a default error callback, two ideas #266

@radarsat1

Description

@radarsat1

Looking at #228, the idea is that it is problematic not to be able to provide an error handler before the API was initialized, making it impossible to catch and display warnings in some other context.

Two ideas to handle this:

  1. Provide a static default RtMidi::setDefaultErrorHandler which can be called early in the program and will be used if no RtMidi object has a specific handler set. This is implemented here: radarsat1@c5bff5e
  2. The other way I thought of is to specify such a callback as an argument to RtMidiIn and RtMidiOut constructors, so that they are available at the earliest moment. This is implemented here: radarsat1@5d7a494

To be honest I am not sure which is best, they both seem to have some advantages. For (2), the default value for the parameter is nullptr, so it is not required to give anything here and RtMidi will work just as before. Similar for (1), if setDefaultErrorHandler is not called. So neither changes the API.

I think it comes down to preference, so asking for opinions. Constructor arguments or static function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions