Skip to content

Commit

Permalink
Changed error messages appearing in bofh for the "ou info" command
Browse files Browse the repository at this point in the history
  • Loading branch information
Christina Skåre Nordtømme committed Jan 24, 2023
1 parent e73df78 commit dfa0822
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions Cerebrum/modules/bofhd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,12 @@ def get_target_disk(path):
def get_target_ou_by_stedkode(stedkode):
ou = Factory.get("OU")(self.db)

if len(stedkode) != 6 or not stedkode.isdigit():
raise CerebrumError("Expected a six-digit stedkode.")

try:
ou.find_stedkode(
stedkode[0:2],
stedkode[2:4],
stedkode[4:6],
cereconf.DEFAULT_INSTITUSJONSNR
)
ou.find_sko(stedkode)
except ValueError:
raise CerebrumError("Expected a six-digit stedkode")
except Errors.NotFoundError:
raise CerebrumError("Stedkode %s was not found." % stedkode)

raise CerebrumError("Could not find Organizational Unit with stedkode=%s" % stedkode)
return ou

#
Expand Down

0 comments on commit dfa0822

Please sign in to comment.