Skip to content

Commit d8f80a9

Browse files
ENH: Add custom exceptions for RocketPy library - UnstableRocketException
1 parent 2931c30 commit d8f80a9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

rocketpy/exceptions.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Custom exceptions for RocketPy library.
3+
"""
4+
5+
6+
class RocketPyException(Exception):
7+
"""All RocketPy custom exceptions should inherit from this class."""
8+
9+
10+
class UnstableRocketError(RocketPyException):
11+
"""Raised when the rocket jas negative static margin."""
12+
13+
def __init__(self, stability_margin):
14+
self.stability_margin = stability_margin
15+
self.message = (
16+
"Rocket is unstable. Initial Static Margin is "
17+
f"{stability_margin} calibers, this can lead to eternal loop simulation."
18+
)
19+
20+
def __str__(self):
21+
return self.message

0 commit comments

Comments
 (0)