Skip to content

Commit 4c43f49

Browse files
committed
Update code docs
1 parent e08f0e9 commit 4c43f49

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

docs/components_tasks_PostTask.bs.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,36 @@
1616
print "ERROR in PostTask. Invalid API URL provided"
1717
return
1818
end if
19+
20+
if m.global.session.server.url = ""
21+
print "ERROR in PostTask. No server URL set in session"
22+
m.top.responseCode = -1
23+
m.top.failureReason = "No server URL set in session"
24+
return
25+
end if
26+
1927
if m.top.arrayData.count() > 0 and m.top.stringData = ""
2028
print "PostTask Started - Posting array to " + m.top.apiUrl
2129
req = APIRequest(m.top.apiUrl)
30+
if not isValid(req)
31+
print "ERROR in PostTask. Failed to create API request for " + m.top.apiUrl
32+
m.top.responseCode = -1
33+
m.top.failureReason = "Failed to create API request"
34+
return
35+
end if
2236
req.SetRequest("POST")
2337
httpResponse = asyncPost(req, FormatJson(m.top.arrayData))
2438
m.top.responseCode = httpResponse
2539
print "PostTask Finished. " + m.top.apiUrl + " Response = " + httpResponse.toStr()
2640
else if m.top.arrayData.count() = 0 and m.top.stringData <> ""
2741
print "PostTask Started - Posting string(" + m.top.stringData + ") to " + m.top.apiUrl
2842
req = APIRequest(m.top.apiUrl)
43+
if not isValid(req)
44+
print "ERROR in PostTask. Failed to create API request for " + m.top.apiUrl
45+
m.top.responseCode = -1
46+
m.top.failureReason = "Failed to create API request"
47+
return
48+
end if
2949
req.SetRequest("POST")
3050
httpResponse = asyncPost(req, m.top.stringData)
3151
m.top.responseCode = httpResponse
@@ -47,6 +67,13 @@
4767
' NOTE: wait() uses milliseconds - multiply by 1000 to convert
4868
resp = wait(m.top.timeoutSeconds * 1000, req.GetMessagePort())
4969

70+
' Check if we got a valid response
71+
if type(resp) <> "roUrlEvent"
72+
print "ERROR in asyncPost: Did not receive roUrlEvent, got: " + type(resp)
73+
m.top.failureReason = "Network request timeout or invalid response type"
74+
return -1
75+
end if
76+
5077
respString = resp.GetString()
5178
if isValidAndNotEmpty(respString)
5279
m.top.responseBody = ParseJson(respString)
@@ -57,9 +84,14 @@
5784
if respCode < 0
5885
' there was an unexpected error
5986
m.top.failureReason = resp.GetFailureReason()
87+
print "ERROR in asyncPost: HTTP error code " + respCode.toStr() + ", reason: " + m.top.failureReason
6088
else if respCode >= 200 and respCode < 300
6189
' save response headers if they're available
6290
m.top.responseHeaders = resp.GetResponseHeaders()
91+
else
92+
' HTTP error response
93+
m.top.failureReason = "HTTP error: " + respCode.toStr()
94+
print "ERROR in asyncPost: HTTP error " + respCode.toStr()
6395
end if
6496

6597
return respCode

docs/source_Main.bs.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
setGlobalNodes()
3535

3636
app_start:
37+
m.global.sceneManager.callFunc("clearScenes")
3738
' First thing to do is validate the ability to use the API
3839
if not LoginFlow() then return
3940

@@ -54,12 +55,18 @@
5455
if isValid(configEncoding) and isValid(configEncoding.EnableFallbackFont)
5556
if configEncoding.EnableFallbackFont
5657
re = CreateObject("roRegex", "Name.:.(.*?).,.Size", "s")
57-
filename = APIRequest("FallbackFont/Fonts").GetToString()
58-
if isValid(filename)
59-
filename = re.match(filename)
60-
if isValid(filename) and filename.count() > 0
61-
filename = filename[1]
62-
APIRequest("FallbackFont/Fonts/" + filename).gettofile("tmp:/font")
58+
fontReq = APIRequest("FallbackFont/Fonts")
59+
if isValid(fontReq)
60+
filename = fontReq.GetToString()
61+
if isValid(filename)
62+
filename = re.match(filename)
63+
if isValid(filename) and filename.count() > 0
64+
filename = filename[1]
65+
fontFileReq = APIRequest("FallbackFont/Fonts/" + filename)
66+
if isValid(fontFileReq)
67+
fontFileReq.gettofile("tmp:/font")
68+
end if
69+
end if
6370
end if
6471
end if
6572
end if

0 commit comments

Comments
 (0)