Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

create_student_teams fails and quits for nonexisting users #128

Open
Soly opened this issue Feb 12, 2016 · 0 comments
Open

create_student_teams fails and quits for nonexisting users #128

Soly opened this issue Feb 12, 2016 · 0 comments

Comments

@Soly
Copy link

Soly commented Feb 12, 2016

teachers_pet doesn't fail gracefully for nonexisting users.
This issue probably exists for some other commands too.

My current workaround for create_student_teams is this, which just catches the error and continues.

--- a/lib/teachers_pet/client_decorator.rb
+++ b/lib/teachers_pet/client_decorator.rb
@@ -52,8 +52,12 @@ module TeachersPet
             puts " -> @#{username} is already on @#{organization}/#{team[:name]}"
           else
             # https://github.com/octokit/octokit.rb/pull/518
-            self.add_team_membership(team[:id], username, accept: 'application/vnd.github.the-wasp-preview+json')
-            puts " -> @#{username} has been added to @#{organization}/#{team[:name]}"
+            begin
+              self.add_team_membership(team[:id], username, accept: 'application/vnd.github.the-wasp-preview+json')
+              puts " -> @#{username} has been added to @#{organization}/#{team[:name]}"
+            rescue
+              puts " -> Error adding user to team. #{username} might not exist."
+            end
           end
         end
       end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant