我不明白如何处理从网络包接收的错误。我需要知道发生了什么类型的错误才能执行下一步。尝试解析错误消息字符串可能不是正确的方法...
response, err := data.httpClient.Get("https://" + domain)
if err != nil {
fmt.Println("[!] error: ", err)
/*
* I want something like this in pseudo code:
* if error == DnsLookupError {
* action1()
* } else if error == TlsCertificateError {
* action2()
* } else if error == Timeout {
* action3()
* } ...
*/
}
例如,我收到的错误消息:
Get "https://example1.com": remote error: tls: internal error
Get "https://example2.com": dial tcp: lookup example2.com
etc.
FFIVE
相关分类