diff --git a/go_backend/exports.go b/go_backend/exports.go index 0e6f2afc..1943b566 100644 --- a/go_backend/exports.go +++ b/go_backend/exports.go @@ -1512,11 +1512,19 @@ func GetSearchProvidersJSON() (string, error) { // Returns JSON with type, tracks, album info, etc. func HandleURLWithExtensionJSON(url string) (string, error) { manager := GetExtensionManager() - result, extensionID, err := manager.HandleURLWithExtension(url) + resultWithID, err := manager.HandleURLWithExtension(url) if err != nil { return "", err } + result := resultWithID.Result + extensionID := resultWithID.ExtensionID + + // Check if result is nil (handler found but returned error) + if result == nil { + return "", fmt.Errorf("extension %s failed to handle URL", extensionID) + } + // Build response response := map[string]interface{}{ "type": result.Type, diff --git a/go_backend/extension_providers.go b/go_backend/extension_providers.go index 193e7d4c..b24c5645 100644 --- a/go_backend/extension_providers.go +++ b/go_backend/extension_providers.go @@ -1210,19 +1210,32 @@ func (m *ExtensionManager) FindURLHandler(url string) *ExtensionProviderWrapper return nil } +// ExtURLHandleResultWithExtID wraps ExtURLHandleResult with extension ID for gomobile compatibility +type ExtURLHandleResultWithExtID struct { + Result *ExtURLHandleResult + ExtensionID string +} + // HandleURLWithExtension tries to handle a URL with any matching extension -func (m *ExtensionManager) HandleURLWithExtension(url string) (*ExtURLHandleResult, string, error) { +// Returns result with extension ID, or error if no handler found +func (m *ExtensionManager) HandleURLWithExtension(url string) (*ExtURLHandleResultWithExtID, error) { handler := m.FindURLHandler(url) if handler == nil { - return nil, "", fmt.Errorf("no extension found to handle URL: %s", url) + return nil, fmt.Errorf("no extension found to handle URL: %s", url) } result, err := handler.HandleURL(url) if err != nil { - return nil, handler.extension.ID, err + return &ExtURLHandleResultWithExtID{ + Result: nil, + ExtensionID: handler.extension.ID, + }, err } - return result, handler.extension.ID, nil + return &ExtURLHandleResultWithExtID{ + Result: result, + ExtensionID: handler.extension.ID, + }, nil } // GetPostProcessingProviders returns all extensions that provide post-processing