|
3 | 3 | from ddsc.core.util import KindType, REMOTE_PATH_SEP, RemotePath |
4 | 4 | from ddsc.core.localstore import HashUtil |
5 | 5 | from ddsc.core.userutil import UserUtil, DUKE_EMAIL_SUFFIX |
| 6 | +from ddsc.exceptions import DDSUserException |
6 | 7 |
|
7 | 8 | FETCH_ALL_USERS_PAGE_SIZE = 25 |
8 | 9 | DOWNLOAD_FILE_CHUNK_SIZE = 20 * 1024 * 1024 |
@@ -110,7 +111,7 @@ def lookup_user_by_name(self, full_name): |
110 | 111 | if found_cnt == 0: |
111 | 112 | raise NotFoundError("User not found:" + full_name) |
112 | 113 | elif found_cnt > 1: |
113 | | - raise ValueError("Multiple users with name:" + full_name) |
| 114 | + raise DDSUserException("Multiple users with name:" + full_name) |
114 | 115 | user = RemoteUser(results[0]) |
115 | 116 | if user.full_name.lower() != full_name.lower(): |
116 | 117 | raise NotFoundError("User not found:" + full_name) |
@@ -142,7 +143,7 @@ def get_or_register_user_by_email(self, email): |
142 | 143 | if affiliate: |
143 | 144 | user_json = util.register_user_by_username(affiliate['uid']) |
144 | 145 | else: |
145 | | - raise ValueError("Unable to find or register a user with email {}".format(email)) |
| 146 | + raise DDSUserException("Unable to find or register a user with email {}".format(email)) |
146 | 147 | return RemoteUser(user_json) |
147 | 148 |
|
148 | 149 | def get_auth_providers(self): |
@@ -272,7 +273,7 @@ def delete_project(self, project_name_or_id): |
272 | 273 | if project: |
273 | 274 | self.data_service.delete_project(project.id) |
274 | 275 | else: |
275 | | - raise ValueError("No project with {} found.\n".format(project_name_or_id.description())) |
| 276 | + raise DDSUserException("No project with {} found.\n".format(project_name_or_id.description())) |
276 | 277 |
|
277 | 278 | def get_active_auth_roles(self, context): |
278 | 279 | """ |
@@ -435,7 +436,7 @@ def get_upload_from_json(json_data): |
435 | 436 | if 'upload' in json_data: |
436 | 437 | return json_data['upload'] |
437 | 438 | else: |
438 | | - raise ValueError("Invalid file json data, unable to find upload.") |
| 439 | + raise DDSUserException("Invalid file json data, unable to find upload.") |
439 | 440 |
|
440 | 441 | @staticmethod |
441 | 442 | def get_hash_from_upload(upload, target_algorithm=HashUtil.HASH_NAME): |
@@ -572,7 +573,7 @@ def __init__(self, json_data): |
572 | 573 | self.login_initiation_url = json_data['login_initiation_url'] |
573 | 574 |
|
574 | 575 |
|
575 | | -class NotFoundError(Exception): |
| 576 | +class NotFoundError(DDSUserException): |
576 | 577 | def __init__(self, message): |
577 | 578 | Exception.__init__(self, message) |
578 | 579 | self.message = message |
|
0 commit comments