{ "id": "62375", "key": "TIMOB-1743", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-08-07T19:52:51.000+0000", "created": "2011-04-15T03:01:09.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [ { "id": "11367", "description": "", "name": "Release 1.7.1", "archived": true, "released": true, "releaseDate": "2011-06-21" } ], "issuelinks": [ { "id": "19738", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "79053", "key": "TIMOB-4971", "fields": { "summary": "Platform Inconsistency: HTTPClient's onerror's e.error is not consistently set for Android and iOS", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-08-07T19:54:32.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h1. Problem\r\nOn iOS, the HTTPClient's onerror handler e.error returns a generic message and not what the server is really returning, and on Android e.error gets the custom status description.\r\n\r\nSO to get past this we should fix Android so that it returns the same generic message, and for iOS and Android, move the custom status description in to a new property: e.statusDescription\r\n\r\nh2. Reproduction\r\nDrop the following in an app.js. It will display \"FAIL:\" and tell you if the server's response is not being utilized.\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow({ backgroundColor: '#fff' });\r\nvar label = Ti.UI.createLabel({ color: '#000', text: 'Loading...', textAlign: 'center' });\r\nwin.add(label);\r\nwin.open();\r\n\r\nvar client = Ti.Network.createHTTPClient({\r\n onload: function() {\r\n label.text = 'FAIL! onload handler fired for a request that should have errored.';\r\n },\r\n onerror: function(e) {\r\n if (e.statusDescription != 'This is a custom status description for error code 402!') {\r\n label.text = 'FAIL! e.statusDescription != the custom status description for error code 402!';\r\n }\r\n else {\r\n label.text = 'PASS! The e.statusDescription was properly set, and the onerror handler was used.'\r\n }\r\n }\r\n});\r\nclient.open('GET', 'http://appc.me/test/SimulateResponse/?code=402');\r\nclient.send();\r\n{code}\r\n\r\nh2. Workaround\r\nThere is no workaround, as there is no way to get at the status description from JavaScript at the moment.\r\n\r\nh3. Associated Helpdesk Ticket\r\nhttp://appc.me/c/XLD-83444-775", "attachment": [], "flagged": false, "summary": "Platform Inconsistency: HTTPClient's onerror's e.error is not consistently set for Android and iOS", "creator": { "name": "ctredway1", "key": "ctredway1", "displayName": "ctredway", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Tested with Titanium Mobile SDK 1.7.1\r\nBROKEN in iPhone Simulator 4.3\r\nWORKS on Android Device EPIC 4G 2.2", "comment": { "comments": [ { "id": "156771", "author": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This error is still reproducible in Titanium 1.7 SDK, iOS 4.3. The link for the sample code is given below.\r\n\r\nhttp://www.pastie.org/2069773\r\n\r\n- Anirudh Nagesh\r\n", "updateAuthor": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-14T17:40:01.000+0000", "updated": "2011-06-14T17:40:01.000+0000" }, { "id": "159516", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Updated code body and changed reporter to me. Changed customer priority to reflect the pro and enterprise interest in it.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-07-14T09:48:58.000+0000", "updated": "2011-07-14T09:48:58.000+0000" }, { "id": "162320", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Updated the example to be significantly more explicit when it fails.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-09T20:53:51.000+0000", "updated": "2011-08-09T20:53:51.000+0000" }, { "id": "162322", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "I'm still seeing this behavior. I updated the example to more clearly draw out the difference between Android and iOS. I also changed this from being a \"feature request\" -- it's a difference between the platforms that needs to be corrected. Plus, the server is returning something that iOS is ignoring when it constructs the error message.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-09T20:56:33.000+0000", "updated": "2011-08-09T20:56:33.000+0000" }, { "id": "162326", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Bumped to next release (1.9.0) so that we can flesh out the changes to both platforms that will be necessary.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-08-09T21:24:15.000+0000", "updated": "2011-08-09T21:24:15.000+0000" }, { "id": "168885", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The error code in the event is not the HTTP error code from the response. It could be null pointer or some other issue.\r\n\r\n{{this.status}} contains the HTTP error code and at least on Android {{this.statusText}} contains the description of the error. I propose that a new ticket for {{statusText}} be added for iOS and this ticket closed as invalid.", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-11T15:13:37.000+0000", "updated": "2011-10-11T15:13:37.000+0000" }, { "id": "169137", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "httpClient's statusText has existed in iOS since August. If anything, this needs documentation.", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-13T09:37:58.000+0000", "updated": "2011-10-13T09:37:58.000+0000" }, { "id": "169691", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "methods already exist for checking status.", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-19T10:31:22.000+0000", "updated": "2011-10-19T10:31:22.000+0000" }, { "id": "169966", "author": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Confirmed working with this.status and this.statusText\r\n\r\nh4. Tested with \r\n1.8.0.v20111006001414\r\niOS Simulator 4.3\r\nAndroid Emulator 2.2\r\n\r\n{code:title=Example Code}\r\n// Example code:\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : '#fff'\r\n});\r\nvar label = Ti.UI.createLabel({\r\n\tcolor : '#000',\r\n\ttext : 'Loading...',\r\n\ttextAlign : 'center'\r\n});\r\nwin.add(label);\r\nwin.open();\r\n\r\nwin.addEventListener('click', function() {\r\n\tvar client = Ti.Network.createHTTPClient({\r\n\t\tonload : function(e) {\r\n\t\t\tTi.API.info('####ONload#####: '+JSON.stringify(e) );\r\n\t\t\tTi.API.info('statusText '+this.statusText);\r\n\t\t\tTi.API.info('status '+this.status);\r\n\t\t\tlabel.text = 'FAIL! onload handler fired for a request that should have errored.';\r\n\t\t},\r\n\t\tonerror : function(e) {\r\n\t\t\tTi.API.info('####ONERROR#####: '+JSON.stringify(e) );\r\n\t\t\tTi.API.info('statusText '+this.statusText);\r\n\t\t\tTi.API.info('status '+this.status);\r\n\t\t\tif(e.statusDescription != 'This is a custom status description for error code 402!') {\r\n\t\t\t\tlabel.text = 'FAIL! e.statusDescription != the custom status description for error code 402!';\r\n\t\t\t} else {\r\n\t\t\t\tlabel.text = 'PASS! The e.statusDescription was properly set, and the onerror handler was used.'\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n\tclient.open('GET', 'http://appc.me/test/SimulateResponse/?code=402');\r\n\t// client.setTimeout(1);\r\n\tclient.send();\r\n});\r\n{code}\r\n{code:title=Android}\r\nI/TiAPI ( 285): (kroll$1: app://app.js) [2,3610] ####ONERROR#####: {\"error\":\"This is a custom status description for error code 402!\"}\r\nI/TiAPI ( 285): (kroll$1: app://app.js) [2,3612] statusText This is a custom status description for error code 402!\r\nI/TiAPI ( 285): (kroll$1: app://app.js) [8,3620] status 402\r\n{code}\r\n{code:title=iOS}\r\n[INFO] ####ONERROR#####: {\"source\":{},\"type\":\"error\"}\r\n[INFO] statusText HTTP/1.1 402 This is a custom status description for error code 402!\r\n[INFO] status 402\r\n{code}", "updateAuthor": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-20T18:01:18.000+0000", "updated": "2011-10-20T18:24:51.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }