From b805ab8d5e9dab182e59d9d9364f6bf556723ac6 Mon Sep 17 00:00:00 2001
From: "Michael D. M. Dryden" <mdryden@chem.utoronto.ca>
Date: Mon, 10 Nov 2014 17:57:33 -0500
Subject: [PATCH] Move errors into separate file.

---
 dstat-interface/dstat-interface/dstat_comm.py |  1 +
 dstat-interface/dstat-interface/errors.py     | 47 +++++++++++++++++++
 dstat-interface/dstat-interface/main.py       | 17 +------
 3 files changed, 49 insertions(+), 16 deletions(-)
 create mode 100644 dstat-interface/dstat-interface/errors.py

diff --git a/dstat-interface/dstat-interface/dstat_comm.py b/dstat-interface/dstat-interface/dstat_comm.py
index 645f0af..eed6de6 100644
--- a/dstat-interface/dstat-interface/dstat_comm.py
+++ b/dstat-interface/dstat-interface/dstat_comm.py
@@ -22,6 +22,7 @@ from serial.tools import list_ports
 import time
 import struct
 import multiprocessing as mp
+from errors import VarError
 
 def call_it(instance, name, args=(), kwargs=None):
     """Indirect caller for instance methods and multiprocessing.
diff --git a/dstat-interface/dstat-interface/errors.py b/dstat-interface/dstat-interface/errors.py
new file mode 100644
index 0000000..9661262
--- /dev/null
+++ b/dstat-interface/dstat-interface/errors.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#     DStat Interface - An interface for the open hardware DStat potentiostat
+#     Copyright (C) 2014  Michael D. M. Dryden - 
+#     Wheeler Microfluidics Laboratory <http://microfluidics.utoronto.ca>
+#         
+#     
+#     This program is free software: you can redistribute it and/or modify
+#     it under the terms of the GNU 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 General Public License for more details.
+#     
+#     You should have received a copy of the GNU General Public License
+#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+class Error(Exception):
+    """Copies Exception class"""
+    pass
+
+class InputError(Error):
+    """Exception raised for errors in the input. Extends Error class.
+        
+    Attributes:
+        expr -- input expression in which the error occurred
+        msg  -- error message
+    """
+    
+    def __init__(self, expr, msg):
+        self.expr = expr
+        self.msg = msg
+
+class VarError(Error):
+    """Exception raised for internal variable errors. Extends Error class.
+        
+    Attributes:
+        var -- var in which the error occurred
+        msg  -- error message
+    """
+    
+    def __init__(self, var, msg):
+        self.var = var
+        self.msg = msg
\ No newline at end of file
diff --git a/dstat-interface/dstat-interface/main.py b/dstat-interface/dstat-interface/main.py
index 574cf39..4ce8c7a 100644
--- a/dstat-interface/dstat-interface/main.py
+++ b/dstat-interface/dstat-interface/main.py
@@ -44,27 +44,12 @@ import interface.exp_window as exp_window
 import interface.adc_pot as adc_pot
 import plot
 import microdrop
+from errors import InputError, VarError
 
 from serial import SerialException
 import multiprocessing
 import time
 
-class Error(Exception):
-    """Copies Exception class"""
-    pass
-
-class InputError(Error):
-    """Exception raised for errors in the input. Extends Error class.
-        
-    Attributes:
-        expr -- input expression in which the error occurred
-        msg  -- error message
-    """
-    
-    def __init__(self, expr, msg):
-        self.expr = expr
-        self.msg = msg
-
 class Main(object):
     """Main program """
     def __init__(self):
-- 
GitLab