Package Products :: Package ZenUtils :: Module Exceptions |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenUtils.Exceptions

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9  from exceptions import ImportError, Exception
    10  from zope.dottedname.resolve import resolve
    11
    12
    13 -class ZentinelException(Exception):
    14      """Root of all Zentinel Exceptions"""
    15      pass
    16
    17
    18 -class ZenPathError(ZentinelException):
    19      """When walking a path something along the way wasn't found."""
    20      pass
    21
    22
    23 -def resolveException(failure):
    24      """
    25      Resolves a twisted.python.failure into the remote exception type that was
    26      initially raised.
    27      """
    28      exctype = failure.type
    29      if isinstance(exctype, basestring):
    30          try:
    31              exctype = resolve(failure.type)
    32          except ImportError:
    33              exctype = Exception
    34      return exctype(failure.value, failure.tb)
    35