# Path: twimp/error.py
# class CommandResultError(RuntimeError):
#     def __str__(self):
#         desc = None
#         if (self.args and len(self.args) == 2 and
#             isinstance(self.args[1], amf0.Object)):
#             obj = self.args[1]
#             if obj.has_key('description'):
#                 desc = '%s: %s' % (obj.get('code', self.__class__.__name__),
#                                    obj.description)
#         return desc or RuntimeError.__str__(self)


from twimp.error import CommandResultError
#   Copyright (c) 2011  Arek Korbik
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.




def check_get_rejected_desc(failure):
    if failure.check(CommandResultError):
        _n, args = failure.value.args
        if (args.code == 'NetConnection.Connect.Rejected' and
            args.level == 'error'):

# Path: twimp/error.py
# class CommandResultError(RuntimeError):
#     def __str__(self):
#         desc = None
#         if (self.args and len(self.args) == 2 and
#             isinstance(self.args[1], amf0.Object)):
#             obj = self.args[1]
#             if obj.has_key('description'):
#                 desc = '%s: %s' % (obj.get('code', self.__class__.__name__),
#                                    obj.description)
#         return desc or RuntimeError.__str__(self)


# Path: twimp/auth/helpers.py
from twimp.error import CommandResultError

#   Copyright (c) 2011  Arek Korbik
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.




def check_get_rejected_desc(failure):
    if failure.check(CommandResultError):
        _n, args = failure.value.args
        if (args.code == 'NetConnection.Connect.Rejected' and
            args.level == 'error'):

            return args.description