Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions control/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,44 @@
#
# $Id$


class ControlSlycot(Exception):
"""Exception for Slycot import. Used when we can't import a function
from the slycot package"""
pass
def __init__(self, error):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is the right approach to immediately print this error reason. This creates an exception with a by-product.

This also does not call Exception.init, (which would normally store the error string) so if caught and printed later, the original exception reason has disappeared.

print("slycot import failed")
print(error)


class ControlDimension(Exception):
"""Raised when dimensions of system objects are not correct"""
pass


class ControlArgument(Exception):
"""Raised when arguments to a function are not correct"""
pass


class ControlMIMONotImplemented(Exception):
"""Function is not currently implemented for MIMO systems"""
pass


class ControlNotImplemented(Exception):
"""Functionality is not yet implemented"""
pass


# Utility function to see if slycot is installed
def slycot_check():
try:
import slycot
except:
except ImportError as error:
print(error)
return False
except Exception as exception:
print(exception, False)
return False
else:
return True
Loading