HTML5 media.hasSource unhandling error

I`ve got unhandled error when I use media.hasSource like this:

local hasAccessToPhotos, hasPhotos = media.hasSource( media.PhotoLibrary )

if (hasAccessToPhotos) then
     media.selectPhoto({mediaSource=media.PhotoLibrary, listener = loadingComplete})
end

In JS MediaDevices.getUserMedia() can be used only in https connections. In other way user will get this exceptions:

Error: MediaRecorder requires getUserMedia supported

Runtime:addEventListener( “unhandledError”) cannot catch this exception

Is there any best practise?

P.S. for better understanding: in this case “hasAccessToPhotos” and “hasPhotos” is both “true”