-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MDS-5607] - Exception handling + Email Notification (#2824)
* code for 5607 and 5617, TODO: username in the email * exception updated * resolving exception import * update exception * email body change * adding Exception to mine resources and modules * updating the error email * updating email body * resolving core-web minespace diff * resolving merge conflicts * updating env * setting env variable to read the email address for notificaiton * fixing email config env var * fixing cypress tests with new env. var * fixing cypress tests * changing email resource to report error * removed unnecessary env var * adding feature flag + formatting email * correcting typo
- Loading branch information
Showing
16 changed files
with
493 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
services/core-api/app/api/exception/mds_core_api_exceptions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class MDSCoreAPIException(Exception): | ||
"""A base Exception class for MDS Core API""" | ||
|
||
description = ( | ||
"Exception occurred in MDS Core API" | ||
) | ||
|
||
def __init__(self, message="Oops! Something went wrong", **kwargs): | ||
super().__init__(message) | ||
self.code = int(kwargs.get("status_code", 500)) | ||
self.message = message | ||
self.detailed_error = kwargs.get("detailed_error", "") |
42 changes: 42 additions & 0 deletions
42
services/core-api/app/api/mines/exceptions/mine_exceptions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import json | ||
from app.api.exception.mds_core_api_exceptions import MDSCoreAPIException | ||
|
||
class MineException(MDSCoreAPIException): | ||
"""A Custom Exception for Errors in MINE Namespace""" | ||
|
||
description = ( | ||
"Generic exeption for errors occurred in the Mine module" | ||
) | ||
def __init__(self, message = "Oops! Something went wrong", **kwargs): | ||
super().__init__(message, **kwargs) | ||
self.code = int(kwargs.get("status_code", 500)) | ||
|
||
class ExplosivesPermitDocumentException(MineException): | ||
"""Exception for Explosives Permit Document Related Exception""" | ||
|
||
description = ( | ||
"Exception For Explosives Permit Document Related Errors" | ||
) | ||
def __init__(self, message = "An error occurred while processing Explosives Permit Document", **kwargs): | ||
super().__init__(message, **kwargs) | ||
self.code = int(kwargs.get("status_code", 500)) | ||
|
||
class ExplosivesPermitExeption(MineException): | ||
"""Exception for Explosive Permit related errors""" | ||
|
||
description = ( | ||
"Exception for errors in Explosive Permit" | ||
) | ||
def __init__(self, message = "Error in Explosive Permit", **kwargs): | ||
super().__init__(message, **kwargs) | ||
self.code = int(kwargs.get("status_code", 500)) | ||
|
||
class ExplosivePermitNumberAlreadyExistExeption(MineException): | ||
"""Exception for already existing permit number""" | ||
|
||
description = ( | ||
"Exception for already existing permit number" | ||
) | ||
def __init__(self, message = "A record already exists with the provided 'Explosives Permit Number'", **kwargs): | ||
super().__init__(message, **kwargs) | ||
self.code = int(kwargs.get("status_code", 422)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.