6.7. foundations.exceptions

exceptions.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module defines Foundations package exceptions and others exception handling related objects.

Others:

6.7.1. Module Attributes

foundations.exceptions.LOGGER
foundations.exceptions.EXCEPTIONS_FRAME_SYMBOL

6.7.2. Functions

foundations.exceptions.getInnerMostFrame(trcback)[source]

This definition returns the inner most frame of given traceback.

Parameters:trcback – Traceback. ( Traceback )
Returns:Frame. ( Frame )
foundations.exceptions.extractStack(frame, context=10, exceptionsFrameSymbol='_exceptions__frame__')[source]

This definition extracts the stack from given frame while excluded any symbolized frame.

Parameters:
  • frame – Frame. ( Frame )
  • context – Context to extract. ( Integer )
  • exceptionsFrameSymbol – Stack trace frame tag. ( String )
Returns:

Stack. ( List )

foundations.exceptions.extractArguments(frame)[source]

This definition extracts the arguments from given frame.

Parameters:frame – Frame. ( Object )
Returns:Arguments. ( Tuple )
foundations.exceptions.extractLocals(trcback)[source]

This definition extracts the frames locals of given traceback.

Parameters:trcback – Traceback. ( Traceback )
Returns:Frames locals. ( List )
foundations.exceptions.extractException(*args)[source]

This definition extracts the exception from given arguments or from sys.exc_info().

Parameters:*args – Arguments. ( * )
Returns:Extracted exception. ( Tuple )
foundations.exceptions.formatException(cls, instance, trcback, context=1)[source]
This definition formats given exception.
The code produce a similar output to traceback.format_exception() except that it allows frames to be excluded from the stack if the given stack trace frame tag is found in the frame locals and set True.
Parameters:
  • cls – Exception class. ( Object )
  • instance – Exception instance. ( Object )
  • trcback – Traceback. ( Traceback )
  • context – Context being included. ( Integer )
Returns:

Formated exception. ( List )

foundations.exceptions.formatReport(cls, instance, trcback, context=1)[source]

This definition formats a report using given exception.

Parameters:
  • cls – Exception class. ( Object )
  • instance – Exception instance. ( Object )
  • trcback – Traceback. ( Traceback )
  • context – Context being included. ( Integer )
Returns:

Formated report. ( Tuple )

foundations.exceptions.baseExceptionHandler(*args)[source]

This definition provides the base exception handler.

Parameters:*args – Arguments. ( * )
Returns:Definition success. ( Boolean )
foundations.exceptions.installExceptionHandler(handler=None)[source]

This definition installs the given exceptions handler.

Parameters:handler – Exception handler. ( Object )
Returns:Definition success. ( Boolean )
foundations.exceptions.uninstallExceptionHandler()[source]

This definition uninstalls the exceptions handler.

Returns:Definition success. ( Boolean )
foundations.exceptions.handleExceptions(*args)[source]
This decorator is used for exceptions handling.
It’s possible to specify an user defined exception handler, if not, baseExceptionHandler() handler will be used.
The decorator uses given exceptions objects or the default Python Exception class.

Usage:

@handleExceptions(ZeroDivisionError)
def raiseAnException(value):
        '''
        This definition raises a 'ZeroDivisionError' exception.
        '''

        return value / 0

        :param \*args: Arguments. ( \* )
Returns:Object. ( Object )

6.7.3. Classes

class foundations.exceptions.AbstractError(value)[source]

Bases: exceptions.Exception

This class is the abstract base class for all Foundations package exceptions.

Parameters:value – Error value or message. ( String )
value[source]

This method is the property for self.__value attribute.

Returns:self.__value. ( Object )
class foundations.exceptions.ExecutionError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is used for execution exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.BreakIteration(value)[source]

Bases: foundations.exceptions.AbstractError

This class is used to break nested loop iterations.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AbstractParsingError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for parsing related exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.FileStructureParsingError(value)[source]

Bases: foundations.exceptions.AbstractParsingError

This class is used for exceptions raised while parsing file structure.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AttributeStructureParsingError(value, line=None)[source]

Bases: foundations.exceptions.AbstractParsingError

This class is used for exceptions raised while parsing attribute structure.

Parameters:
  • value – Error value or message. ( String )
  • line – Line number where exception occured. ( Integer )
line[source]

This method is the property for self.__line attribute.

Returns:self.__line. ( Integer )
class foundations.exceptions.AbstractOsError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for os related exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.PathExistsError(value)[source]

Bases: foundations.exceptions.AbstractOsError

This class is used for non existing path exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.DirectoryExistsError(value)[source]

Bases: foundations.exceptions.PathExistsError

This class is used for non existing directory exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.FileExistsError(value)[source]

Bases: foundations.exceptions.PathExistsError

This class is used for non existing file exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AbstractObjectError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for object related exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.ObjectTypeError(value)[source]

Bases: foundations.exceptions.AbstractObjectError

This class is used for invalid object type exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.ObjectExistsError(value)[source]

Bases: foundations.exceptions.AbstractObjectError

This class is used for non existing object exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AbstractUserError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for user related exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.ProgrammingError(value)[source]

Bases: foundations.exceptions.AbstractUserError

This class is used for programming exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.UserError(value)[source]

Bases: foundations.exceptions.AbstractUserError

This class is used for user exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AbstractNodeError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for Node related exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.NodeAttributeTypeError(value)[source]

Bases: foundations.exceptions.AbstractNodeError, foundations.exceptions.ObjectTypeError

This class is the abstract base class for Node attributes type related exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.NodeAttributeExistsError(value)[source]

Bases: foundations.exceptions.AbstractNodeError, foundations.exceptions.ObjectExistsError

This class is used for non existing Node attribute exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AbstractLibraryError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for library module exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.LibraryInstantiationError(value)[source]

Bases: foundations.exceptions.AbstractLibraryError

This class is used for library module library.Library class instantiation exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.LibraryInitializationError(value)[source]

Bases: foundations.exceptions.AbstractLibraryError

This class is used for library module library.Library class initialization exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.LibraryExecutionError(value)[source]

Bases: foundations.exceptions.AbstractLibraryError

This class is used for library module library.Library class execution exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.AbstractServerError(value)[source]

Bases: foundations.exceptions.AbstractError

This class is the abstract base class for tcpServer module exceptions.

Parameters:value – Error value or message. ( String )
class foundations.exceptions.ServerOperationError(value)[source]

Bases: foundations.exceptions.AbstractServerError

This class is used for tcpServer module tcpServer.TCPServer class operations exceptions.

Parameters:value – Error value or message. ( String )

Table Of Contents

Previous topic

6.6. foundations.environment

Next topic

6.8. foundations.globals.constants

This Page