-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the common directory - common files and functions between all t…
…he patterns
- Loading branch information
Mohanna Shahrad
committed
Aug 25, 2022
1 parent
87a37ed
commit 3b1bade
Showing
4 changed files
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
aws_cdk/common/__pycache__/ |
Empty file.
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,31 @@ | ||
class NoSQL(Exception): | ||
|
||
def __init__(self): | ||
self.message = "No sql statemtnt is provided. Please refer to README.md for more information." | ||
|
||
def __str__(self): | ||
return(repr(self.message)) | ||
|
||
class NoTimestreamDimension(Exception): | ||
|
||
def __init__(self): | ||
self.message = "No dimesnsion is provided. Each record contains an array of dimensions (minimum 1).Please refer to README.md for more information." | ||
|
||
def __str__(self): | ||
return(repr(self.message)) | ||
|
||
class WrongLengthForInput(Exception): | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
|
||
def __str__(self): | ||
return(repr(self.message)) | ||
|
||
class WrongFormattedInput(Exception): | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
|
||
def __str__(self): | ||
return(repr(self.message)) |
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,10 @@ | ||
import re | ||
from common.customExceptions import * | ||
|
||
def checkInputLength(self, min_length, max_length, input, resource_name): | ||
if len(input) < min_length or len(input) > max_length: | ||
raise WrongLengthForInput(f"Invalid input length for {resource_name}'s name. Check the README.md file for more details.") | ||
|
||
def checkInputPattern(self, pattern, input, resource_name): | ||
if not re.match(pattern, input): | ||
raise WrongFormattedInput(f"Invalid input pattern for {resource_name}'s name. Check the README.md file for more details.") |