# Path: lacli/exceptions.py
# class PauseEvent(BaseAppException):
#     msg = "Paused"
# 
# Path: lacli/server/interface/ClientInterface/ttypes.py
# class InvalidOperation(TException):
#   """
#   Attributes:
#    - what
#    - why
#    - filename
#   """
# 
#   thrift_spec = (
#     None, # 0
#     (1, TType.I32, 'what', None, None, ), # 1
#     (2, TType.STRING, 'why', None, None, ), # 2
#     (3, TType.STRING, 'filename', None, None, ), # 3
#   )
# 
#   def __init__(self, what=None, why=None, filename=None,):
#     self.what = what
#     self.why = why
#     self.filename = filename
# 
#   def read(self, iprot):
#     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
#       fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
#       return
#     iprot.readStructBegin()
#     while True:
#       (fname, ftype, fid) = iprot.readFieldBegin()
#       if ftype == TType.STOP:
#         break
#       if fid == 1:
#         if ftype == TType.I32:
#           self.what = iprot.readI32();
#         else:
#           iprot.skip(ftype)
#       elif fid == 2:
#         if ftype == TType.STRING:
#           self.why = iprot.readString();
#         else:
#           iprot.skip(ftype)
#       elif fid == 3:
#         if ftype == TType.STRING:
#           self.filename = iprot.readString();
#         else:
#           iprot.skip(ftype)
#       else:
#         iprot.skip(ftype)
#       iprot.readFieldEnd()
#     iprot.readStructEnd()
# 
#   def write(self, oprot):
#     if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
#       oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
#       return
#     oprot.writeStructBegin('InvalidOperation')
#     if self.what is not None:
#       oprot.writeFieldBegin('what', TType.I32, 1)
#       oprot.writeI32(self.what)
#       oprot.writeFieldEnd()
#     if self.why is not None:
#       oprot.writeFieldBegin('why', TType.STRING, 2)
#       oprot.writeString(self.why)
#       oprot.writeFieldEnd()
#     if self.filename is not None:
#       oprot.writeFieldBegin('filename', TType.STRING, 3)
#       oprot.writeString(self.filename)
#       oprot.writeFieldEnd()
#     oprot.writeFieldStop()
#     oprot.writeStructEnd()
# 
#   def validate(self):
#     return
# 
# 
#   def __str__(self):
#     return repr(self)
# 
#   def __repr__(self):
#     L = ['%s=%r' % (key, value)
#       for key, value in self.__dict__.iteritems()]
#     return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
# 
#   def __eq__(self, other):
#     return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
# 
#   def __ne__(self, other):
#     return not (self == other)
# 
# Path: lacli/server/interface/ClientInterface/ttypes.py
# class ErrorType(object):
#   NoError = 0
#   Server = 1
#   Network = 2
#   Authentication = 3
#   Validation = 4
#   Other = 5
#   NotImplemented = 6
#   FileNotFound = 7
# 
#   _VALUES_TO_NAMES = {
#     0: "NoError",
#     1: "Server",
#     2: "Network",
#     3: "Authentication",
#     4: "Validation",
#     5: "Other",
#     6: "NotImplemented",
#     7: "FileNotFound",
#   }
# 
#   _NAMES_TO_VALUES = {
#     "NoError": 0,
#     "Server": 1,
#     "Network": 2,
#     "Authentication": 3,
#     "Validation": 4,
#     "Other": 5,
#     "NotImplemented": 6,
#     "FileNotFound": 7,
#   }
# 
# Path: lacli/log.py
# def getLogger(logger='lacli'):
#     return lacore.log.getLogger(logger)


from lacore.exceptions import ApiAuthException, BaseAppException
from lacli.exceptions import PauseEvent
from lacli.server.interface.ClientInterface.ttypes import InvalidOperation
from lacli.server.interface.ClientInterface.ttypes import ErrorType
from lacli.log import getLogger
from twisted.python import log as twisted_log
from twisted.internet import defer
from functools import wraps
import errno
            getLogger().debug("{} is not implemented".format(f, r))
            raise InvalidOperation(ErrorType.NotImplemented, str(e))
        except OSError as e:
            getLogger().debug("{} threw exception".format(f), exc_info=True)
            if e.errno == errno.ENOENT:
                raise InvalidOperation(ErrorType.FileNotFound,
                                       "File not found",
                                       filename=e.filename)
            if e.errno == errno.EACCES:
                raise InvalidOperation(
                    ErrorType.Other, "Access denied or file in use")
            getLogger().debug("unknown exception", exc_info=True)
            raise InvalidOperation(ErrorType.Other, "Unknown error")
        except IOError as e:
            getLogger().debug("{} threw exception".format(f), exc_info=True)
            if e.errno == errno.ENOENT:
                raise InvalidOperation(ErrorType.FileNotFound,
                                       "File not found",
                                       filename=e.filename)
            if e.errno == errno.ENOSPC:
                raise InvalidOperation(ErrorType.Other,
                                       "No space left on device")
            getLogger().debug("unknown exception", exc_info=True)
            raise InvalidOperation(ErrorType.Other, "")
        except ValueError as e:
            getLogger().debug("{} threw exception".format(f), exc_info=True)
            raise InvalidOperation(ErrorType.Validation, str(e))
        except BaseAppException as e:
            getLogger().debug("application exception", exc_info=True)
            twisted_log.err(e)

# Path: lacli/exceptions.py
# class PauseEvent(BaseAppException):
#     msg = "Paused"
# 
# Path: lacli/server/interface/ClientInterface/ttypes.py
# class InvalidOperation(TException):
#   """
#   Attributes:
#    - what
#    - why
#    - filename
#   """
# 
#   thrift_spec = (
#     None, # 0
#     (1, TType.I32, 'what', None, None, ), # 1
#     (2, TType.STRING, 'why', None, None, ), # 2
#     (3, TType.STRING, 'filename', None, None, ), # 3
#   )
# 
#   def __init__(self, what=None, why=None, filename=None,):
#     self.what = what
#     self.why = why
#     self.filename = filename
# 
#   def read(self, iprot):
#     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
#       fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
#       return
#     iprot.readStructBegin()
#     while True:
#       (fname, ftype, fid) = iprot.readFieldBegin()
#       if ftype == TType.STOP:
#         break
#       if fid == 1:
#         if ftype == TType.I32:
#           self.what = iprot.readI32();
#         else:
#           iprot.skip(ftype)
#       elif fid == 2:
#         if ftype == TType.STRING:
#           self.why = iprot.readString();
#         else:
#           iprot.skip(ftype)
#       elif fid == 3:
#         if ftype == TType.STRING:
#           self.filename = iprot.readString();
#         else:
#           iprot.skip(ftype)
#       else:
#         iprot.skip(ftype)
#       iprot.readFieldEnd()
#     iprot.readStructEnd()
# 
#   def write(self, oprot):
#     if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
#       oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
#       return
#     oprot.writeStructBegin('InvalidOperation')
#     if self.what is not None:
#       oprot.writeFieldBegin('what', TType.I32, 1)
#       oprot.writeI32(self.what)
#       oprot.writeFieldEnd()
#     if self.why is not None:
#       oprot.writeFieldBegin('why', TType.STRING, 2)
#       oprot.writeString(self.why)
#       oprot.writeFieldEnd()
#     if self.filename is not None:
#       oprot.writeFieldBegin('filename', TType.STRING, 3)
#       oprot.writeString(self.filename)
#       oprot.writeFieldEnd()
#     oprot.writeFieldStop()
#     oprot.writeStructEnd()
# 
#   def validate(self):
#     return
# 
# 
#   def __str__(self):
#     return repr(self)
# 
#   def __repr__(self):
#     L = ['%s=%r' % (key, value)
#       for key, value in self.__dict__.iteritems()]
#     return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
# 
#   def __eq__(self, other):
#     return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
# 
#   def __ne__(self, other):
#     return not (self == other)
# 
# Path: lacli/server/interface/ClientInterface/ttypes.py
# class ErrorType(object):
#   NoError = 0
#   Server = 1
#   Network = 2
#   Authentication = 3
#   Validation = 4
#   Other = 5
#   NotImplemented = 6
#   FileNotFound = 7
# 
#   _VALUES_TO_NAMES = {
#     0: "NoError",
#     1: "Server",
#     2: "Network",
#     3: "Authentication",
#     4: "Validation",
#     5: "Other",
#     6: "NotImplemented",
#     7: "FileNotFound",
#   }
# 
#   _NAMES_TO_VALUES = {
#     "NoError": 0,
#     "Server": 1,
#     "Network": 2,
#     "Authentication": 3,
#     "Validation": 4,
#     "Other": 5,
#     "NotImplemented": 6,
#     "FileNotFound": 7,
#   }
# 
# Path: lacli/log.py
# def getLogger(logger='lacli'):
#     return lacore.log.getLogger(logger)


# Path: lacli/server/error.py
from lacore.exceptions import ApiAuthException, BaseAppException
from lacli.exceptions import PauseEvent
from lacli.server.interface.ClientInterface.ttypes import InvalidOperation
from lacli.server.interface.ClientInterface.ttypes import ErrorType
from lacli.log import getLogger
from twisted.python import log as twisted_log
from twisted.internet import defer
from functools import wraps
import errno

            getLogger().debug("{} is not implemented".format(f, r))
            raise InvalidOperation(ErrorType.NotImplemented, str(e))
        except OSError as e:
            getLogger().debug("{} threw exception".format(f), exc_info=True)
            if e.errno == errno.ENOENT:
                raise InvalidOperation(ErrorType.FileNotFound,
                                       "File not found",
                                       filename=e.filename)
            if e.errno == errno.EACCES:
                raise InvalidOperation(
                    ErrorType.Other, "Access denied or file in use")
            getLogger().debug("unknown exception", exc_info=True)
            raise InvalidOperation(ErrorType.Other, "Unknown error")
        except IOError as e:
            getLogger().debug("{} threw exception".format(f), exc_info=True)
            if e.errno == errno.ENOENT:
                raise InvalidOperation(ErrorType.FileNotFound,
                                       "File not found",
                                       filename=e.filename)
            if e.errno == errno.ENOSPC:
                raise InvalidOperation(ErrorType.Other,
                                       "No space left on device")
            getLogger().debug("unknown exception", exc_info=True)
            raise InvalidOperation(ErrorType.Other, "")
        except ValueError as e:
            getLogger().debug("{} threw exception".format(f), exc_info=True)
            raise InvalidOperation(ErrorType.Validation, str(e))
        except BaseAppException as e:
            getLogger().debug("application exception", exc_info=True)
            twisted_log.err(e)

            raise InvalidOperation(ErrorType.Other, str(e))