-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Escape-Technologies/docs/better-errors-logs
feat: better errors logs
- Loading branch information
Showing
5 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ main | |
.vscode | ||
.idea | ||
._* | ||
.env |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package stream | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"google.golang.org/grpc/status" | ||
) | ||
|
||
func invalidClientID(msg string) bool { return msg == "invalid client UUID" } | ||
func noSuchHost(msg string) bool { return strings.Contains(msg, "no such host") } | ||
func timedOut(msg string) bool { return strings.Contains(msg, "i/o timeout") } | ||
|
||
func grpcErrorFmt(s *status.Status) []string { | ||
res := []string{} | ||
if s == nil { | ||
return res | ||
} | ||
|
||
msg := s.Message() | ||
if invalidClientID(msg) { | ||
res = append(res, "Server rejected your configured client UUID (configuration issue)") | ||
res = append(res, "Check that the ESCAPE_REPEATER_ID environment variable is set correctly") | ||
res = append(res, "Go to https://app.escape.tech/organization/network/ to retrieve your repeaters list") | ||
|
||
return res | ||
} | ||
|
||
if noSuchHost(msg) { | ||
res = append(res, "Server could not be resolved (DNS issue)") | ||
res = append(res, "If you run inside docker, try passing the --network=host flag") | ||
res = append(res, "From the host machine, check that the server is reachable with nslookup repeater.escape.tech") | ||
} | ||
|
||
if timedOut(msg) { | ||
res = append(res, "Timed out connecting to the server (network issue)") | ||
res = append(res, "It may be linked to a firewall missconfiguration or a network issue") | ||
res = append(res, "Check that the documentation about firewall configuration https://docs.escape.tech/platform/enterprise/repeater#configure-your-firewall") | ||
res = append(res, "You can also try to run tracepath or tcptraceroute to check where the connection is blocked") | ||
} | ||
|
||
res = append(res, "If you need more help to debug this issue, please contact the support team with the result of a curl -v https://repeater.escape.tech") | ||
return res | ||
} | ||
|
||
func extractWhyStreamCreateError(err error) []string { | ||
res := []string{} | ||
if err == nil { | ||
return res | ||
} | ||
|
||
res = append(res, fmt.Sprintf("Error creating stream: %v", err)) | ||
if s, ok := status.FromError(err); ok { | ||
res = append(res, grpcErrorFmt(s)...) | ||
} | ||
|
||
return res | ||
} | ||
|
||
func extractWhyRecvError(err error) []string { | ||
if err == nil { | ||
return []string{} | ||
} | ||
res := []string{} | ||
|
||
res = append(res, fmt.Sprintf("Error receiving data: %v", err)) | ||
if s, ok := status.FromError(err); ok { | ||
res = append(res, grpcErrorFmt(s)...) | ||
} | ||
|
||
return res | ||
} |
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