@dazn/kopytko-framework 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazn/kopytko-framework",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "A modern Roku's Brightscript framework",
5
5
  "keywords": [
6
6
  "brightscript",
@@ -67,7 +67,7 @@ function HttpRequest(options as Object, httpInterceptors = [] as Object) as Obje
67
67
  prototype.send = function () as Object
68
68
  method = m.getMethod()
69
69
 
70
- if (method <> "POST" AND method <> "PUT") then m._headers.delete("Content-Type")
70
+ if (method <> "PATCH" AND method <> "POST" AND method <> "PUT") then m._headers.delete("Content-Type")
71
71
  m._urlTransfer.setHeaders(m._headers)
72
72
 
73
73
  for each interceptor in m._httpInterceptors
@@ -76,7 +76,7 @@ function HttpRequest(options as Object, httpInterceptors = [] as Object) as Obje
76
76
 
77
77
  if (method = "GET")
78
78
  m._urlTransfer.asyncGetToString()
79
- else if (method = "POST" OR method = "PUT" OR method = "DELETE")
79
+ else if (method = "PATCH" OR method = "POST" OR method = "PUT" OR method = "DELETE")
80
80
  body = ""
81
81
 
82
82
  if (m._options.body <> Invalid)
@@ -32,11 +32,16 @@ sub handleResponse(response as Object)
32
32
  result = CreateObject("roSGNode", "HttpRequestResultModel")
33
33
  result.isSuccess = response.isSuccess
34
34
 
35
- if (response.isSuccess)
36
- result.data = parseResponse(response)
37
- else
38
- result.data = generateErrorData(response)
39
- end if
35
+ try
36
+ if (response.isSuccess)
37
+ result.data = parseResponse(response)
38
+ else
39
+ result.data = generateErrorData(response)
40
+ end if
41
+ catch error
42
+ result.isSuccess = false
43
+ result.data = generateParseErrorData(response, error)
44
+ end try
40
45
 
41
46
  m.top.result = result
42
47
  end sub
@@ -42,6 +42,11 @@ function generateErrorData(response as Object) as Object
42
42
  return response
43
43
  end function
44
44
 
45
+ ' Override by child for returning a specific data structure and/or node type
46
+ function generateParseErrorData(response as Object, _error as Object) as Object
47
+ return response
48
+ end function
49
+
45
50
  sub _onDataChange(event as Object)
46
51
  data = event.getData()
47
52