From 8d3b7548d7033c1af12f55ca5eb8d1cf49eb4060 Mon Sep 17 00:00:00 2001 From: AJ Schuster Date: Thu, 20 Jun 2024 10:56:42 -0400 Subject: [PATCH] Provide helpful error if type assertion fails. Fix #4. Co-authored-by: Abigail Chen <6415144+abigailychen@users.noreply.github.com> --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 42f991a..cd52a5e 100644 --- a/main.go +++ b/main.go @@ -102,7 +102,11 @@ func cli() error { return fmt.Errorf("could not unmarshal: %w", err) } - data := graphqlResponse["data"].(map[string]interface{}) + data, ok := graphqlResponse["data"].(map[string]interface{}) + + if !ok { + return fmt.Errorf("could not parse response.\n\nyou may need to add the appropriate scopes to your token.\ntry running the following:\n\tgh auth refresh --scopes user:email,read:user") + } for _, user := range data { if user == nil {