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

AlgoResponse third failure case needs a better description. #2

Open
zeryx opened this issue Jul 24, 2017 · 0 comments
Open

AlgoResponse third failure case needs a better description. #2

zeryx opened this issue Jul 24, 2017 · 0 comments

Comments

@zeryx
Copy link
Contributor

zeryx commented Jul 24, 2017

The code snippet below is hard to decypher, I think the third failure case is thrown when the response is unable to be decoded into the requested type; which seems to occur when any algorithm error is thrown.

  /**
   * Parse server response into an AlgoResponse
   */
  def apply(rawOutput: String, outputType: AlgorithmOutputType): AlgoResponse = {
    val json = Json.parse(rawOutput)
    Json.fromJson[AlgoResponseRaw](json) match {
      case JsSuccess(AlgoResponseRaw(result, None, metadata),_) => AlgoSuccess(result, metadata.metadata, rawOutput)
      case JsSuccess(AlgoResponseRaw(_, Some(error), metadata),_) => AlgoFailure(error.message, metadata.metadata, rawOutput)
      case JsError(_) => AlgoFailure("Failed to parse algorithm response", Metadata(0, ContentTypeVoid, None), rawOutput)
    }
  }

Maybe this section should be more descriptive if this is intended functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant