From 1a866f4d1f58e5c9f48bdd7492ed35e8d7dd6543 Mon Sep 17 00:00:00 2001 From: Davis Goglin Date: Tue, 15 Mar 2016 12:01:15 -0700 Subject: [PATCH] Add config parser exceptions --- escpos/exceptions.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/escpos/exceptions.py b/escpos/exceptions.py index ce2667a..3b1ac1a 100644 --- a/escpos/exceptions.py +++ b/escpos/exceptions.py @@ -13,6 +13,8 @@ Result/Exit codes: - `80` = Invalid char code :py:exc:`~escpos.exceptions.CharCodeError` - `90` = USB device not found :py:exc:`~escpos.exceptions.USBNotFoundError` - `100` = Set variable out of range :py:exc:`~escpos.exceptions.SetVariableError` + - `200` = Configuration not found :py:exc:`~escpos.exceptions.ConfigNotFoundError` + - `210` = Configuration syntax error :py:exc:`~escpos.exceptions.ConfigSyntaxError` :author: `Manuel F Martinez `_ and others :organization: Bashlinux and `python-escpos `_ @@ -188,3 +190,34 @@ class SetVariableError(Error): def __str__(self): return "Set variable out of range" + + +# Configuration errors + +class ConfigNotFoundError(Error): + """ The configuration file was not found + + The default or passed configuration file could not be read + Ths returncode for this exception is `200`. + """ + def __init__(self, msg=""): + Error.__init__(self, msg) + self.msg = msg + self.resultcode = 200 + + def __str__(self): + return "Configuration not found ({msg})".format(msg=self.msg) + +class ConfigSyntaxError(Error): + """ The configuration file is invalid + + The syntax is incorrect or there is a section missing + Ths returncode for this exception is `210`. + """ + def __init__(self, msg=""): + Error.__init__(self, msg) + self.msg = msg + self.resultcode = 210 + + def __str__(self): + return "Configuration syntax is invalid ({msg})".format(msg=self.msg)