-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
728aeda
commit 234b14d
Showing
4 changed files
with
79 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,73 @@ | ||
"""exception.py""" | ||
|
||
|
||
class iTachException(Exception): | ||
"""iTachException Exception""" | ||
|
||
def __init__(self, response): | ||
if not isinstance(response, str): | ||
pass | ||
elif response.startswith("ERR_01"): | ||
message = "Invalid command. Command not found." | ||
"""init method""" | ||
message = self.error_handler(response) | ||
super(iTachException, self).__init__(message) | ||
self.message = message | ||
|
||
def error_handler(self, response): | ||
"""error handler""" | ||
if response.startswith("ERR_01"): | ||
response = self.invalid_error("command. Command not found.") | ||
elif response.startswith("ERR_02"): | ||
message = "Invalid module address (does not exist)." | ||
response = self.invalid_error("module address (does not exist).") | ||
elif response.startswith("ERR_03"): | ||
message = "Invalid connector address (does not exist)." | ||
response = self.invalid_error("connector address (does not exist).") | ||
elif response.startswith("ERR_04"): | ||
message = "Invalid ID value." | ||
response = self.invalid_error("ID value.") | ||
elif response.startswith("ERR_05"): | ||
message = "Invalid frequency value" | ||
response = self.invalid_error("frequency value") | ||
elif response.startswith("ERR_06"): | ||
message = "Invalid repeat value." | ||
response = self.invalid_error("repeat value.") | ||
elif response.startswith("ERR_07"): | ||
message = "Invalid offset value." | ||
response = self.invalid_error("offset value.") | ||
elif response.startswith("ERR_08"): | ||
message = "Invalid pulse count." | ||
response = self.invalid_error("pulse count.") | ||
elif response.startswith("ERR_09"): | ||
message = "Invalid pulse data." | ||
response = self.invalid_error("pulse data.") | ||
elif response.startswith("ERR_10"): | ||
message = "Uneven amount of <on|off> statements." | ||
response = "Uneven amount of <on|off> statements." | ||
elif response.startswith("ERR_11"): | ||
message = "No carriage return found." | ||
response = "No carriage return found." | ||
elif response.startswith("ERR_12"): | ||
message = "Repeat count exceeded." | ||
response = "Repeat count exceeded." | ||
elif response.startswith("ERR_13"): | ||
message = "IR command sent to input connector." | ||
response = "IR command sent to input connector." | ||
elif response.startswith("ERR_14"): | ||
message = "Blaster command sent to non-blaster connector." | ||
response = "Blaster command sent to non-blaster connector." | ||
elif response.startswith("ERR_15"): | ||
message = "No carriage return before buffer full." | ||
response = "No carriage return before buffer full." | ||
elif response.startswith("ERR_16"): | ||
message = "No carriage return." | ||
response = "No carriage return." | ||
elif response.startswith("ERR_17"): | ||
message = "Bad command syntax." | ||
response = "Bad command syntax." | ||
elif response.startswith("ERR_18"): | ||
message = "Sensor command sent to non-input connector." | ||
response = "Sensor command sent to non-input connector." | ||
elif response.startswith("ERR_19"): | ||
message = "Repeated IR transmission failure." | ||
response = "Repeated IR transmission failure." | ||
elif response.startswith("ERR_20"): | ||
message = "Above designated IR <on|off> pair limit." | ||
response = "Above designated IR <on|off> pair limit." | ||
elif response.startswith("ERR_21"): | ||
message = "Symbol odd boundary." | ||
response = "Symbol odd boundary." | ||
elif response.startswith("ERR_22"): | ||
message = "Undefined symbol." | ||
response = "Undefined symbol." | ||
elif response.startswith("ERR_23"): | ||
message = "Unknown option." | ||
response = "Unknown option." | ||
elif response.startswith("ERR_24"): | ||
message = "Invalid baud rate setting." | ||
response = self.invalid_error("baud rate setting.") | ||
elif response.startswith("ERR_25"): | ||
message = "Invalid flow control setting." | ||
response = self.invalid_error("flow control setting.") | ||
elif response.startswith("ERR_26"): | ||
message = "Invalid parity setting." | ||
response = self.invalid_error("parity setting.") | ||
elif response.startswith("ERR_27"): | ||
message = "Settings are locked." | ||
message = response | ||
response = "Settings are locked." | ||
return response | ||
|
||
def invalid_error(self, message): | ||
"""invalid error""" | ||
return "Invalid " + 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
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