Skip to content

Conversation

Copy link

Copilot AI commented Jan 9, 2026

Consolidates 10 separate error domains (SFBAudioDecoderErrorDomain, SFBDSDDecoderErrorDomain, SFBAudioEncoderErrorDomain, etc.) into a single SFBAudioEngineErrorDomain containing all existing error codes.

Changes

  • New unified domain: SFBAudioEngineErrorDomain (@"org.sbooth.AudioEngine") with 14 error codes organized by category (General, Format, Decoder, Encoder, File, I/O Source, Analyzer)
  • Backward compatibility: All legacy error domain names and error codes are centralized in SFBAudioEngineErrors.h via #define macros
  • Header organization: Only SFBAudioEngine.h includes SFBAudioEngineErrors.h - component public headers do not include it
  • Implementation files: 60+ implementation files directly include SFBAudioEngineErrors.h where error codes are used
  • Centralized error handling: Single error info provider in SFBAudioEngineErrors.m replaces 10 duplicate implementations (~220 lines removed)
  • Improved clarity: Distinct error messages for semantically similar format-related codes (InvalidFormat, UnsupportedFormat, FormatNotSupported)

Example

Existing code continues to work unchanged:

// Old usage still works
NSError *error = [NSError errorWithDomain:SFBAudioDecoderErrorDomain 
                                     code:SFBAudioDecoderErrorCodeInvalidFormat 
                                 userInfo:nil];

// New unified domain can also be used directly
NSError *error = [NSError errorWithDomain:SFBAudioEngineErrorDomain 
                                     code:SFBAudioEngineErrorCodeInvalidFormat 
                                 userInfo:nil];

Both approaches produce identical errors due to macro aliasing defined in SFBAudioEngineErrors.h.

Benefits

  • Cleaner public API with minimal header dependencies
  • Better compile times (fewer transitive includes)
  • Clear separation between public umbrella header and component headers
  • All error definitions accessible where needed without polluting public headers
Original prompt

Please draft a pull request that consolidates the various error domains and error codes into a single error domain containing the existing error codes, combining them when possible.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Consolidate error domains and codes into a single domain Consolidate error domains into unified SFBAudioEngineErrorDomain Jan 9, 2026
Copilot AI requested a review from sbooth January 9, 2026 02:07
@sbooth
Copy link
Owner

sbooth commented Jan 9, 2026

@copilot Please move the defines for legacy compatibilty to SFBAudioEngineErrors.h and include the new error header in the implementation files where the errors are used.

Copy link
Author

Copilot AI commented Jan 9, 2026

@copilot Please move the defines for legacy compatibilty to SFBAudioEngineErrors.h and include the new error header in the implementation files where the errors are used.

Done in commit e9b1045. All legacy compatibility defines have been moved to SFBAudioEngineErrors.h and each header now includes the error header via #import <SFBAudioEngine/SFBAudioEngineErrors.h>.

@sbooth
Copy link
Owner

sbooth commented Jan 9, 2026

@copilot The only public header that should include SFBAudioEngineErrors.h is SFBAudioEngine.h. The other public headers do not need that include since it is not required. It should be included in the implementation files that need the error codes.

Copy link
Author

Copilot AI commented Jan 9, 2026

@copilot The only public header that should include SFBAudioEngineErrors.h is SFBAudioEngine.h. The other public headers do not need that include since it is not required. It should be included in the...

Done in commit ca9a043. Removed SFBAudioEngineErrors.h include from all component public headers - only SFBAudioEngine.h includes it now. Added the include directly to 60+ implementation files that use error codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants