Add more details to error messages

This commit is contained in:
Brahim Hadriche committed 2022-12-04 15:28:47 -05:00
1 parent 3131f85653
commit 7f7564f66b
4 files changed
+20 -9

No files matched your search

+11 -3
View File
@@ -65,14 +65,23 @@ function OnVideoDetailsTaskResults() as void
if videoId <> m.top.videoId
return
end if
if metadata = invalid
if not metadata.success
m.busySpinner.visible = false
m.busySpinner.control = "stop"
ShowDialog(`Failed to load video information for ${videoId}`, "Video load fail")
message = `Failed to load video information for ${videoId}`
message += `\nStatus Code: ${metadata.statusCode}`
if isstr(metadata.data)
message += `\nError: ${metadata.data}`
else if isAssocArray(metadata.data)
message += `\nError: ${FormatJson(metadata.data)}`
end if
ShowDialog(message, "Video load fail")
CloseVideo()
return
end if
metadata = metadata.data
contentNode = CreateObject("roSGNode", "ContentNode")
contentNode.addFields({ metadata: metadata })
@@ -85,7 +94,6 @@ function OnVideoDetailsTaskResults() as void
#else
contentNode.url = metadata.dashUrl
#end if
else
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
itag = stream.itag
@@ -57,7 +57,7 @@ namespace Http
return metadata
end if
metadata = Invidious.GetVideoMetadata(videoId)
return metadata
return metadata.success ? metadata.data : invalid
end function
function InjectStoryBoard(router as object, dash as string, metadata as object) as string
+5 -5
View File
@@ -47,11 +47,11 @@ namespace Invidious
args = Invidious.DefaultArgs()
response = Requests().get(url, args)
' TODO: handle 500 {"error":"This video is unavailable"}
if response.statuscode = 200
return response.json
end if
return invalid
return {
success: response.statuscode = 200,
statusCode: response.statuscode,
data: response.json ?? response.text
}
end function
function SearchSuggestions(q as string) as object 'SearchSuggestionResult
+3
View File
@@ -60,6 +60,9 @@ function isstr(obj as dynamic) as boolean
return obj <> invalid and GetInterface(obj, "ifString") <> invalid
end function
function isAssocArray(obj as dynamic) as boolean
return obj <> invalid and GetInterface(obj, "ifAssociativeArray") <> invalid
end function
'******************************************************
'isbool