redkyn / assigner

:black_nib: Automatically assign programming homework to students on GitLab.
MIT License
27 stars 6 forks source link

Proper error handling for when a repo does not exist #37

Closed LinuxMercedes closed 7 years ago

LinuxMercedes commented 7 years ago

In the situation where assigner tries to act on a repo that doesn't exist (maybe you added a student between assign and open, for example), the error you get is something like:

Traceback (most recent call last):
  File "/usr/local/home/nmjxv3/src/assigner/assigner.py", line 749, in <module>
    main()
  File "/usr/local/home/nmjxv3/src/assigner/assigner.py", line 740, in main
    raise e
  File "/usr/local/home/nmjxv3/src/assigner/assigner.py", line 737, in main
    args.run(args)
  File "/usr/local/home/nmjxv3/src/assigner/config.py", line 11, in wrapper
    return func(conf, cmdargs, *args)
  File "/usr/local/home/nmjxv3/src/assigner/assigner.py", line 157, in open_assignment
    repo.add_member(student["id"], Access.developer)
  File "/usr/local/home/nmjxv3/src/assigner/baserepo.py", line 218, in add_member
    "id": self.id,
  File "/usr/local/home/nmjxv3/src/assigner/baserepo.py", line 131, in id
    return self.info["id"]
TypeError: 'NoneType' object is not subscriptable

The main issue lies on line 142 of baserepo.py. Should we silently fail in the case of a 404, or force the caller to handle that?