File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -8,15 +8,13 @@ const (
88 clientConextKey ctxKey = "client"
99)
1010
11- func WithClient (ctx context.Context , tkn string ) context.Context {
12- ctx , cancel := context .WithCancelCause (ctx )
13-
11+ func WithClient (ctx context.Context , tkn string ) (context.Context , error ) {
1412 c , err := New (ctx , tkn )
1513 if err != nil {
16- cancel ( err )
14+ return nil , err
1715 }
1816
19- return context .WithValue (ctx , clientConextKey , c )
17+ return context .WithValue (ctx , clientConextKey , c ), nil
2018}
2119
2220func ClientFromContext (ctx context.Context ) (* Client , error ) {
Original file line number Diff line number Diff line change @@ -42,9 +42,14 @@ func Execute() {
4242 c .Github .Token = tkn
4343 }
4444
45- ctx := client .WithClient (context .Background (), c .Github .Token )
45+ ctx , err := client .WithClient (context .Background (), c .Github .Token )
46+ if err != nil {
47+ fmt .Printf ("Error: %s\n " , err .Error ())
48+ os .Exit (1 )
49+ }
4650
47- if err := rootCmd .ExecuteContext (ctx ); err != nil {
51+ err = rootCmd .ExecuteContext (ctx )
52+ if err != nil {
4853 fmt .Printf ("Error: %s\n " , err .Error ())
4954 os .Exit (1 )
5055 }
You can’t perform that action at this time.
0 commit comments