# -*- coding: utf-8 -*-

# Part of the masterfile package: https://github.com/njvack/masterfile
# Copyright (c) 2017 Board of Regents of the University of Wisconsin System
# Written by Nate Vack <njvack@wisc.edu> at the Center for Healthy Minds
# at the University of Wisconsin-Madison.
# Released under MIT licence; see LICENSE at the package root.


from __future__ import absolute_import, unicode_literals

from .vendor import attr


@attr.s
class Error(object):

    code = attr.ib()

    location = attr.ib()

    message = attr.ib()

    root_exception = attr.ib(default=None)


ERROR_CODES = {
    'E1': 'Columns',
    'E101': 'index column not found',
    'E102': 'duplicate column name',
    'E9': 'I/O',
    'E901': 'Cannot read file',
}

@@ -464,30 +464,8 @@
 ):%0A%0A
-    code = attr.ib()%0A%0A
     
@@ -559,106 +559,144 @@
 e)%0A%0A
-%0AERROR_CODES = %7B%0A    'E1': 'Columns',%0A    'E101': 'index column not found',%0A    'E102': 'd
+    code = None%0A%0A%0Aclass ColumnError(Error):%0A    code = 'E1'%0A%0A%0Aclass IndexNotFoundError(ColumnError):%0A    code = 'E101'%0A%0A%0Aclass D
 uplicate
  col
@@ -695,70 +695,138 @@
 cate
- c
+C
 olumn
- name',%0A    'E9': 'I/O',%0A    'E901': 'Cannot read file',%0A%7D
+Error(ColumnError):%0A    code = 'E102'%0A%0A%0Aclass IOError(Error):%0A    code = 'E9'%0A%0A%0Aclass FileReadError(IOError):%0A    code = 'E901'
 %0A

Make errors use their own classes