Created
December 10, 2019 08:34
-
-
Save kkdai/58e776a1387d3db2c032492269601d58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parseVideoInfo(videoInfo string) error { | |
answer, err := url.ParseQuery(videoInfo) | |
if err != nil { | |
return err | |
} | |
status, ok := answer["status"] | |
if !ok { | |
err = fmt.Errorf("no response status found in the server's answer") | |
return err | |
} | |
if status[0] == "fail" { | |
reason, ok := answer["reason"] | |
if ok { | |
err = fmt.Errorf("'fail' response status found in the server's answer, reason: '%s'", reason[0]) | |
} else { | |
err = errors.New(fmt.Sprint("'fail' response status found in the server's answer, no reason given")) | |
} | |
return err | |
} | |
if status[0] != "ok" { | |
err = fmt.Errorf("non-success response status found in the server's answer (status: '%s')", status) | |
return err | |
} | |
///.... Continue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment