Skip to content

Commit

Permalink
Get rid of spurrious documentation. Ready for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dbhart committed Mar 11, 2024
1 parent f3588ff commit db2a2d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 177 deletions.
167 changes: 0 additions & 167 deletions documentation/errors.rst

This file was deleted.

22 changes: 12 additions & 10 deletions wntr/epanet/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
309: "cannot save results to report file %s",
}
"""A dictionary of the error codes and their meanings from the EPANET toolkit.
Please see :doc:`/errors` for descriptions of these values.
:meta hide-value:
"""
Expand All @@ -98,27 +97,28 @@ def __init__(self, code: int, *args: List[object], line_num=None, line=None) ->
code : int
The EPANET error code
args : additional non-keyword arguments, optional
If there is a string-format within the error code's text, these will be used to
If there is a string-format within the error code's text, these will be used to
replace the format, otherwise they will be output at the end of the Exception message.
line_num : int, optional
The line number, if reading an INP file, by default None
line : str, optional
The contents of the line, by default None
"""
msg = EN_ERROR_CODES.get(code, 'unknown error')
msg = EN_ERROR_CODES.get(code, "unknown error")
if args is not None:
args = [*args]
if r'%' in msg and len(args) > 0:
if r"%" in msg and len(args) > 0:
msg = msg % repr(args.pop(0))
if len(args) > 0:
msg = msg + ' ' + repr(args)
msg = msg + " " + repr(args)
if line_num:
msg = msg + ", at line {}".format(line_num)
if line:
msg = msg + ':\n ' + str(line)
msg = '(Error {}) '.format(code) + msg
msg = msg + ":\n " + str(line)
msg = "(Error {}) ".format(code) + msg
super().__init__(msg)


class ENSyntaxError(EpanetException, SyntaxError):
def __init__(self, code, *args, line_num=None, line=None) -> None:
"""An EPANET exception class that also subclasses SyntaxError
Expand All @@ -128,7 +128,7 @@ def __init__(self, code, *args, line_num=None, line=None) -> None:
code : int
The EPANET error code
args : additional non-keyword arguments, optional
If there is a string-format within the error code's text, these will be used to
If there is a string-format within the error code's text, these will be used to
replace the format, otherwise they will be output at the end of the Exception message.
line_num : int, optional
The line number, if reading an INP file, by default None
Expand All @@ -137,6 +137,7 @@ def __init__(self, code, *args, line_num=None, line=None) -> None:
"""
super().__init__(code, *args, line_num=line_num, line=line)


class ENKeyError(EpanetException, KeyError):
def __init__(self, code, name, *args, line_num=None, line=None) -> None:
"""An EPANET exception class that also subclasses KeyError.
Expand All @@ -148,7 +149,7 @@ def __init__(self, code, name, *args, line_num=None, line=None) -> None:
name : str
The key/name/id that is missing
args : additional non-keyword arguments, optional
If there is a string-format within the error code's text, these will be used to
If there is a string-format within the error code's text, these will be used to
replace the format, otherwise they will be output at the end of the Exception message.
line_num : int, optional
The line number, if reading an INP file, by default None
Expand All @@ -158,6 +159,7 @@ def __init__(self, code, name, *args, line_num=None, line=None) -> None:

super().__init__(code, name, *args, line_num=line_num, line=line)


class ENValueError(EpanetException, ValueError):
def __init__(self, code, value, *args, line_num=None, line=None) -> None:
"""An EPANET exception class that also subclasses ValueError
Expand All @@ -169,7 +171,7 @@ def __init__(self, code, value, *args, line_num=None, line=None) -> None:
value : Any
The value that is invalid
args : additional non-keyword arguments, optional
If there is a string-format within the error code's text, these will be used to
If there is a string-format within the error code's text, these will be used to
replace the format, otherwise they will be output at the end of the Exception message.
line_num : int, optional
The line number, if reading an INP file, by default None
Expand Down

0 comments on commit db2a2d6

Please sign in to comment.