ably / ably-java

Java, Android, Clojure and Scala client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
86 stars 40 forks source link

Extract all HTTP status codes in HttpConstants #837

Open qsdigor opened 1 year ago

qsdigor commented 1 year ago

There are a lot of places where HTTP status codes are hard coded. This is not a good practice as we should use static variables instead. We already have HttpConstants class that contains ContentTypes, Headers, and Methods. What I suggest is that we create a new class inside HttpConstants and specify all error codes used in the app.

This is a sample of the current code implementation if(errorInfo.statusCode == 403)

This is the suggested solution if(errorInfo.statusCode == HTTP_FORBIDEN_403)

┆Issue is synchronized with this Jira Task by Unito

QuintinWillison commented 1 year ago

Static constants, perhaps, or enum probably more suited.