pymbs.exceptions module

PyMBS is a Python library for use in modeling Mortgage-Backed Securities.

Copyright (C) 2019 Brian Farrell

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Contact: brian.farrell@me.com

exception pymbs.exceptions.AssumedCollatError(group_id, repline_num=1)[source]

Bases: Exception

docstring for AssumedCollatError

exception pymbs.exceptions.CollatError(group_id)[source]

Bases: Exception

docstring for AssumedCollatError

exception pymbs.exceptions.DateError(date, message)[source]

Bases: Exception

Exception raised for errors in the input.

Attributes:

expression – input expression in which the error occurred message – explanation of the error

class pymbs.exceptions.GracefulMessage(message, **kwargs)[source]

Bases: object

The GracefulMessage object allows various messages to be displayed in the most appropriate format, depending on how PyMBS is being used at the time.

If PyMBS is being used in something like a Jupyter Notebook, where HTML can be displayed, it will display HTML. If the front-end is only capable of displaying text, it will display plain text.

TODO: Implement a _repr_json_ method to output the error message as a JSON string, for when PyMBS is integrated with a RESTful/GraphQL API.

exception pymbs.exceptions.IpyExit[source]

Bases: SystemExit

Exit Exception for IPython.

Exception temporarily redirects stderr to buffer.

exception pymbs.exceptions.PayRuleError(pay_rule, error)[source]

Bases: Exception

Exception raised for errors in the input.

Attributes:

expression – input expression in which the error occurred message – explanation of the error

exception pymbs.exceptions.PrepaymentBenchmarkError(prepayment_benchmark, message)[source]

Bases: Exception

Exception raised for errors in the input.

Attributes:

expression – input expression in which the error occurred message – explanation of the error

pymbs.exceptions.handle_gracefully(ipython_status: bool, logger: Logger, message: str, **kwargs: str) NoReturn[source]

Handle an error condition in a graceful manner.

Args:
ipython_status: The status as to whether or not PyMBS is running

inside an IPython kernel. This status can be passed with the config._ipython_active attribute.

logger: The logger object, passed in from the caller. This keeps

references in the log to the actual module where the excpeption occured, rather than logging them as occuring inside the exceptions module.

message: A string with the same name as one of the messages available

in the GracefulMessage object, described below, in this module.

kwargs: Keyword arguments, supplying any values interpolated in the

message templates of the GracefulMessage object.