Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Case On Interpreting UnityWebRequest #2

Open
EliCDavis opened this issue Jul 12, 2021 · 0 comments
Open

Switch Case On Interpreting UnityWebRequest #2

EliCDavis opened this issue Jul 12, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@EliCDavis
Copy link
Member

EliCDavis commented Jul 12, 2021

It'd be ideal to replace code like this:

public void Interpret(UnityWebRequest req) {
  if (req.responseCode == 200)
  {
      success = JsonUtility.FromJson<LocationConfiguration>(req.downloadHandler.text);
  }
  else if (req.responseCode == 400)
  {
      badRequest = JsonUtility.FromJson<ErrorMessage>(req.downloadHandler.text);
  }
  else if (req.responseCode == 401)
  {
      unauthorized = JsonUtility.FromJson<ErrorMessage>(req.downloadHandler.text);
  }
  else if (req.responseCode == 403)
  {
      forbidden = JsonUtility.FromJson<ErrorMessage>(req.downloadHandler.text);
  }
  else if (req.responseCode == 404)
  {
      notFound = JsonUtility.FromJson<ErrorMessage>(req.downloadHandler.text);
  }
  else if (req.responseCode == 500)
  {
      internalServerError = JsonUtility.FromJson<ErrorMessage>(req.downloadHandler.text);
  }
}
@EliCDavis EliCDavis added the enhancement New feature or request label Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant