scx.utils
1import sys 2 3 4class Error: 5 @classmethod 6 def warn(self, message, depth=0): 7 """ 8 Usage: 9 10 - Creates a class based warning message 11 12 Requires: 13 14 - `message`: 15 - Type: str 16 - What: The message to warn users with 17 18 Optional: 19 20 - `depth`: 21 - Type: int 22 - What: The depth of the nth call below the top of the method stack 23 - Note: Depth starts at 0 (indicating the current method in the stack) 24 - Default: 0 25 """ 26 print( 27 f"(Warning for `{self.__class__.__name__}.{sys._getframe(depth).f_back.f_code.co_name}`): {message}" 28 ) 29 30 @classmethod 31 def exception(self, message, depth=0): 32 """ 33 Usage: 34 35 - Creates a class based exception message 36 37 Requires: 38 39 - `message`: 40 - Type: str 41 - What: The message to raise an exception with 42 43 Optional: 44 45 - `depth`: 46 - Type: int 47 - What: The depth of the nth call below the top of the method stack 48 - Note: Depth starts at 0 (indicating the current method in the stack) 49 - Default: 0 50 """ 51 raise Exception( 52 f"(`{self.__class__.__name__}.{sys._getframe(depth).f_back.f_code.co_name}`): {message}" 53 )
class
Error:
5class Error: 6 @classmethod 7 def warn(self, message, depth=0): 8 """ 9 Usage: 10 11 - Creates a class based warning message 12 13 Requires: 14 15 - `message`: 16 - Type: str 17 - What: The message to warn users with 18 19 Optional: 20 21 - `depth`: 22 - Type: int 23 - What: The depth of the nth call below the top of the method stack 24 - Note: Depth starts at 0 (indicating the current method in the stack) 25 - Default: 0 26 """ 27 print( 28 f"(Warning for `{self.__class__.__name__}.{sys._getframe(depth).f_back.f_code.co_name}`): {message}" 29 ) 30 31 @classmethod 32 def exception(self, message, depth=0): 33 """ 34 Usage: 35 36 - Creates a class based exception message 37 38 Requires: 39 40 - `message`: 41 - Type: str 42 - What: The message to raise an exception with 43 44 Optional: 45 46 - `depth`: 47 - Type: int 48 - What: The depth of the nth call below the top of the method stack 49 - Note: Depth starts at 0 (indicating the current method in the stack) 50 - Default: 0 51 """ 52 raise Exception( 53 f"(`{self.__class__.__name__}.{sys._getframe(depth).f_back.f_code.co_name}`): {message}" 54 )
@classmethod
def
warn(self, message, depth=0):
6 @classmethod 7 def warn(self, message, depth=0): 8 """ 9 Usage: 10 11 - Creates a class based warning message 12 13 Requires: 14 15 - `message`: 16 - Type: str 17 - What: The message to warn users with 18 19 Optional: 20 21 - `depth`: 22 - Type: int 23 - What: The depth of the nth call below the top of the method stack 24 - Note: Depth starts at 0 (indicating the current method in the stack) 25 - Default: 0 26 """ 27 print( 28 f"(Warning for `{self.__class__.__name__}.{sys._getframe(depth).f_back.f_code.co_name}`): {message}" 29 )
Usage:
- Creates a class based warning message
Requires:
message
:- Type: str
- What: The message to warn users with
Optional:
depth
:- Type: int
- What: The depth of the nth call below the top of the method stack
- Note: Depth starts at 0 (indicating the current method in the stack)
- Default: 0
@classmethod
def
exception(self, message, depth=0):
31 @classmethod 32 def exception(self, message, depth=0): 33 """ 34 Usage: 35 36 - Creates a class based exception message 37 38 Requires: 39 40 - `message`: 41 - Type: str 42 - What: The message to raise an exception with 43 44 Optional: 45 46 - `depth`: 47 - Type: int 48 - What: The depth of the nth call below the top of the method stack 49 - Note: Depth starts at 0 (indicating the current method in the stack) 50 - Default: 0 51 """ 52 raise Exception( 53 f"(`{self.__class__.__name__}.{sys._getframe(depth).f_back.f_code.co_name}`): {message}" 54 )
Usage:
- Creates a class based exception message
Requires:
message
:- Type: str
- What: The message to raise an exception with
Optional:
depth
:- Type: int
- What: The depth of the nth call below the top of the method stack
- Note: Depth starts at 0 (indicating the current method in the stack)
- Default: 0