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

class ApplicationException(Exception):
    """ Base class for all DjangoService Exceptions """
    def __init__(self, *args, **kwargs):
        if len(args) > 1:
            self.message = args[0]
        elif kwargs.get('message', None):
            self.message = kwargs['message']
        super(ApplicationException, self).__init__(*args, **kwargs)

    def get_message(self):
        message = getattr(self, '_message', None)
        if not message:
            message = unicode(self.__class__.__name__)
        return message

    def set_message(self, msg):
        self._message = msg

    message = property(get_message, set_message)

    def __unicode__(self):
        if self.message:
            return self.message
        return u"%s.%s(message=%s)" % (unicode(self.__module__), unicode(self.__class__.__name__), unicode(self.message))

    def __str__(self):
        return str(self.__unicode__())


class InternalException(ApplicationException):
    """ Base exception when an unrecoverable error happens """
    pass


class InvalidOperationException(ApplicationException):
    """ Base class used for invalid operations """
    pass

@@ -231,35 +231,27 @@
 lif 
-kwargs.get('message', None)
+'message' in kwargs
 :%0A  
@@ -281,17 +281,21 @@
 = kwargs
-%5B
+.pop(
 'message
@@ -295,17 +295,17 @@
 message'
-%5D
+)
 %0A       

fix when message on ApplicationException where passed as named argument