coremidi icon indicating copy to clipboard operation
coremidi copied to clipboard

Improve error types

Open BenLeadbetter opened this issue 1 year ago • 1 comments

Improve error types

Most Result return values use an i32 (an OSStatus) as their error variant. This is not ideal for a couple of reasons

  • i32 doesn't implement std::error::Error so Result values from core midi aren't compatible with a lot of common error handling patterns (e.g. anyhow)
  • the OS status return value doesn't always imply an error - a zero indicates success. So using this as the error type just feels a little semantically strange.

BenLeadbetter avatar Aug 19 '24 19:08 BenLeadbetter

I would propose a solution where we create a dedicated coremidi::Error type, which has a method to retrieve the OS status code value.

This would likely be a "breaking change", but perhaps this isn't so bad if the crate is still in the 0.*.* phase.

BenLeadbetter avatar Aug 19 '24 19:08 BenLeadbetter