From 70f7360b92d341912b52a1b5f8506b37d669ea19 Mon Sep 17 00:00:00 2001 From: Lukas Herman Date: Fri, 11 Sep 2020 00:08:28 -0700 Subject: [PATCH] Enhance failed to find driver error message --- mediadevices.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mediadevices.go b/mediadevices.go index 5de13e3..a028631 100644 --- a/mediadevices.go +++ b/mediadevices.go @@ -3,6 +3,7 @@ package mediadevices import ( "fmt" "math" + "strings" "github.com/pion/mediadevices/pkg/driver" "github.com/pion/mediadevices/pkg/prop" @@ -214,7 +215,23 @@ func selectBestDriver(filter driver.FilterFn, constraints MediaTrackConstraints) } if bestDriver == nil { - return nil, MediaTrackConstraints{}, errNotFound + var foundProperties []string + for _, props := range driverProperties { + for _, p := range props { + foundProperties = append(foundProperties, fmt.Sprint(&p)) + } + } + + err := fmt.Errorf(`%w: +============ Found Properties ============ + +%s + +=============== Constraints ============== + +%s +`, errNotFound, strings.Join(foundProperties, "\n\n"), &constraints) + return nil, MediaTrackConstraints{}, err } constraints.selectedMedia = prop.Media{}