[GH-ISSUE #69] Show user any erroneous HTTP response codes #60

Closed
opened 2026-02-28 01:22:58 +03:00 by kerem · 6 comments
Owner

Originally created by @olliebennett on GitHub (Dec 22, 2012).
Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/69

When the server sends any unsuccessful HTTP response code (such as 4XX Client Errors or 5XX Server Errors), the user is presented with the same generic error message as with any other problem:

SMSSync message sending failed. Perhaps it's not configured or there is no Internet connection. Please double check your Internet connection or your configuration.

This hinders debugging, and it would be much more useful to see an error such as:

SMSSync message sending failed. Sync URL returned error code 404.

Given that most users will be at least slightly technical, showing the actual response code from the server could at least allow them to google the issue.

As for what happens to 3XX (Redirect) status codes, I am not sure how these are/should be handled, but unless the redirect is automatically obeyed, these 'error' codes should also be shown to the user. Ideally, of course, a redirect should be followed, but that's another story.

Originally created by @olliebennett on GitHub (Dec 22, 2012). Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/69 When the server sends any unsuccessful [HTTP response code](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes) (such as 4XX Client Errors or 5XX Server Errors), the user is presented with the same generic error message as with any other problem: > SMSSync message sending failed. Perhaps it's not configured or there is no Internet connection. Please double check your Internet connection or your configuration. This hinders debugging, and it would be much more useful to see an error such as: > SMSSync message sending failed. Sync URL returned error code 404. Given that most users will be at least slightly technical, showing the actual response code from the server could at least allow them to google the issue. As for what happens to 3XX (Redirect) status codes, I am not sure how these are/should be handled, but unless the redirect is automatically obeyed, these 'error' codes should also be shown to the user. Ideally, of course, a redirect should be followed, but that's another story.
kerem closed this issue 2026-02-28 01:22:59 +03:00
Author
Owner

@knedlsepp commented on GitHub (Jan 16, 2013):

That would be great. Took me ages to figure out that:
http://server/folder instead of http://server/folder/
would lead to a 301-move and thus SMSSync didn't forward correctly.

<!-- gh-comment-id:12330366 --> @knedlsepp commented on GitHub (Jan 16, 2013): That would be great. Took me ages to figure out that: http://server/folder instead of http://server/folder/ would lead to a 301-move and thus SMSSync didn't forward correctly.
Author
Owner

@eyedol commented on GitHub (Feb 11, 2013):

Related to #68

<!-- gh-comment-id:13400730 --> @eyedol commented on GitHub (Feb 11, 2013): Related to #68
Author
Owner

@olliebennett commented on GitHub (Feb 24, 2013):

What is the arrangement for translating strings with replaceable values? In this case, we need:
Error: Server returned HTTP status code {n}.
which could use a simple text replacement in the code to add the number:
Error: Server returned HTTP status code 404.

This is important for translations which wouldn't have the 404 at the end:
Fel: Servern returnerade HTTP {n} statuskod.

Using the existing code, this doesn't seem possible without a bit of a refactoring of Util.showToast() or similar methods.

The other options:

Let's agree on what's best, and I'll implement it.

<!-- gh-comment-id:14010660 --> @olliebennett commented on GitHub (Feb 24, 2013): What is the arrangement for translating strings with replaceable values? In this case, we need: `Error: Server returned HTTP status code {n}.` which could use a simple text replacement in the code to add the number: `Error: Server returned HTTP status code 404.` This is important for translations which wouldn't have the `404` at the end: `Fel: Servern returnerade HTTP {n} statuskod.` Using the existing code, this doesn't seem possible without a bit of a refactoring of `Util.showToast()` or similar methods. The other options: - create a translation for each error code (ugly and increases barrier for translation, however then we could also include a couple of translated words explaining the error). - get the error status "reason" automatically (in English only) from something like [`org.apache.commons.httpclient.HttpStatus.getStatusText(int statusCode)`](http://hc.apache.org/httpclient-legacy/apidocs/org/apache/commons/httpclient/HttpStatus.html#getStatusText%28int%29). Let's agree on what's best, and I'll implement it.
Author
Owner

@eyedol commented on GitHub (Feb 25, 2013):

@olliebennett The Android translation framework supports replaceable values. So we can do
Error: server returned HTTP status code %d and it will dynamically change %d to the real value during runtime. That way we only have to translate Error:server returned HTTP status code. Also the HTTP status codes are well documented

<!-- gh-comment-id:14028305 --> @eyedol commented on GitHub (Feb 25, 2013): @olliebennett The Android translation framework supports replaceable values. So we can do `Error: server returned HTTP status code %d` and it will dynamically change `%d` to the real value during runtime. That way we only have to translate `Error:server returned HTTP status code`. Also the HTTP status codes are well [documented](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
Author
Owner

@olliebennett commented on GitHub (Feb 28, 2013):

Thanks for that @eyedol - not sure how I missed the relevant section of the docs for formatting strings like that.

I've made some (relatively simple) changes, and pushed them to my feature-errorcodes branch.

I will make a pull request once I'm happy that they've been adequately tested.

<!-- gh-comment-id:14210228 --> @olliebennett commented on GitHub (Feb 28, 2013): Thanks for that @eyedol - not sure how I missed the [relevant section](http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling) of the docs for formatting strings like that. I've made some (relatively simple) changes, and pushed them to my [feature-errorcodes](https://github.com/olliebennett/SMSSync/tree/feature-errorcodes) branch. I will make a pull request once I'm happy that they've been adequately tested.
Author
Owner

@eyedol commented on GitHub (Mar 1, 2013):

Oh great!

<!-- gh-comment-id:14295451 --> @eyedol commented on GitHub (Mar 1, 2013): Oh great!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SMSSync#60
No description provided.