|
1 | 1 | import logging |
2 | 2 |
|
3 | 3 | from servicelib.aiohttp import status |
| 4 | +from servicelib.rabbitmq.rpc_interfaces.catalog.errors import CatalogForbiddenError |
4 | 5 |
|
5 | 6 | from ...exception_handling import ( |
6 | 7 | ExceptionToHttpErrorMap, |
|
9 | 10 | to_exceptions_handlers_map, |
10 | 11 | ) |
11 | 12 | from ...folders.errors import FolderAccessForbiddenError, FolderNotFoundError |
| 13 | +from ...resource_usage.errors import DefaultPricingPlanNotFoundError |
| 14 | +from ...users.exceptions import UserDefaultWalletNotFoundError |
| 15 | +from ...wallets.errors import WalletAccessForbiddenError, WalletNotEnoughCreditsError |
12 | 16 | from ...workspaces.errors import WorkspaceAccessForbiddenError, WorkspaceNotFoundError |
13 | 17 | from ..exceptions import ( |
| 18 | + ClustersKeeperNotAvailableError, |
| 19 | + DefaultPricingUnitNotFoundError, |
| 20 | + NodeNotFoundError, |
| 21 | + ParentNodeNotFoundError, |
14 | 22 | ProjectDeleteError, |
15 | 23 | ProjectGroupNotFoundError, |
| 24 | + ProjectInDebtCanNotChangeWalletError, |
16 | 25 | ProjectInvalidRightsError, |
| 26 | + ProjectInvalidUsageError, |
| 27 | + ProjectNodeRequiredInputsNotSetError, |
17 | 28 | ProjectNotFoundError, |
18 | 29 | ProjectOwnerNotFoundInTheProjectAccessRightsError, |
| 30 | + ProjectStartsTooManyDynamicNodesError, |
19 | 31 | WrongTagIdsInQueryError, |
20 | 32 | ) |
21 | 33 |
|
|
33 | 45 | status.HTTP_404_NOT_FOUND, |
34 | 46 | "Folder not found: {reason}", |
35 | 47 | ), |
| 48 | + NodeNotFoundError: HttpErrorInfo( |
| 49 | + status.HTTP_404_NOT_FOUND, |
| 50 | + "Node '{node_uuid}' not found in project '{project_uuid}'", |
| 51 | + ), |
| 52 | + ParentNodeNotFoundError: HttpErrorInfo( |
| 53 | + status.HTTP_404_NOT_FOUND, |
| 54 | + "Parent node '{node_uuid}' not found", |
| 55 | + ), |
36 | 56 | ProjectDeleteError: HttpErrorInfo( |
37 | 57 | status.HTTP_409_CONFLICT, |
38 | 58 | "Failed to complete deletion of '{project_uuid}': {reason}", |
|
45 | 65 | status.HTTP_403_FORBIDDEN, |
46 | 66 | "Do not have sufficient access rights on project {project_uuid} for this action", |
47 | 67 | ), |
| 68 | + ProjectInvalidUsageError: HttpErrorInfo( |
| 69 | + status.HTTP_422_UNPROCESSABLE_ENTITY, |
| 70 | + "Invalid usage for project", |
| 71 | + ), |
48 | 72 | ProjectNotFoundError: HttpErrorInfo( |
49 | 73 | status.HTTP_404_NOT_FOUND, |
50 | 74 | "Project {project_uuid} not found", |
|
65 | 89 | status.HTTP_400_BAD_REQUEST, |
66 | 90 | "Wrong tag IDs in query", |
67 | 91 | ), |
| 92 | + UserDefaultWalletNotFoundError: HttpErrorInfo( |
| 93 | + status.HTTP_404_NOT_FOUND, |
| 94 | + "User default wallet not found", |
| 95 | + ), |
| 96 | + DefaultPricingPlanNotFoundError: HttpErrorInfo( |
| 97 | + status.HTTP_404_NOT_FOUND, |
| 98 | + "Default pricing plan not found", |
| 99 | + ), |
| 100 | + DefaultPricingUnitNotFoundError: HttpErrorInfo( |
| 101 | + status.HTTP_404_NOT_FOUND, |
| 102 | + "Default pricing unit not found", |
| 103 | + ), |
| 104 | + WalletNotEnoughCreditsError: HttpErrorInfo( |
| 105 | + status.HTTP_402_PAYMENT_REQUIRED, |
| 106 | + "Wallet does not have enough credits. {reason}", |
| 107 | + ), |
| 108 | + ProjectInDebtCanNotChangeWalletError: HttpErrorInfo( |
| 109 | + status.HTTP_402_PAYMENT_REQUIRED, |
| 110 | + "Unable to change the credit account linked to the project. The project is embargoed because the last transaction of {debt_amount} resulted in the credit account going negative.", |
| 111 | + ), |
| 112 | + ProjectStartsTooManyDynamicNodesError: HttpErrorInfo( |
| 113 | + status.HTTP_409_CONFLICT, |
| 114 | + "The maximal amount of concurrently running dynamic services was reached. Please manually stop a service and retry.", |
| 115 | + ), |
| 116 | + ClustersKeeperNotAvailableError: HttpErrorInfo( |
| 117 | + status.HTTP_503_SERVICE_UNAVAILABLE, |
| 118 | + "Clusters-keeper service is not available", |
| 119 | + ), |
| 120 | + ProjectNodeRequiredInputsNotSetError: HttpErrorInfo( |
| 121 | + status.HTTP_409_CONFLICT, |
| 122 | + "Project node is required but input is not set", |
| 123 | + ), |
| 124 | + CatalogForbiddenError: HttpErrorInfo( |
| 125 | + status.HTTP_403_FORBIDDEN, |
| 126 | + "Catalog forbidden: Insufficient access rights for {name}", |
| 127 | + ), |
| 128 | + WalletAccessForbiddenError: HttpErrorInfo( |
| 129 | + status.HTTP_403_FORBIDDEN, |
| 130 | + "Payment required, but the user lacks access to the project's linked wallet: Wallet access forbidden. {reason}", |
| 131 | + ), |
68 | 132 | } |
69 | | - |
70 | 133 | handle_plugin_requests_exceptions = exception_handling_decorator( |
71 | 134 | to_exceptions_handlers_map(_TO_HTTP_ERROR_MAP) |
72 | 135 | ) |
0 commit comments