FTExceptionClass Module

An FTException object gives a way to pass generic information about an exceptional situation.

An FTException object gives a way to pass generic information about an exceptional situation. Methods for dealing with exceptions are defined in the SharedExceptionManagerModule module.

An FTException object wraps:

  • A severity indicator
  • A name for the exception
  • An optional dictionary that contains whatever information is deemed necessary.

It is expected that classes will define exceptions that use instances of the FTException Class.

Defined constants:

  • FT_ERROR_NONE = 0
  • FT_ERROR_WARNING = 1
  • FT_ERROR_FATAL = 2

Initialization

        CALL e  %  initFTException(severity,exceptionName,infoDictionary)

Plus the convenience initializers, which automatically create a FTValueDictionary with a single key called "message":

    CALL e % initWarningException(msg = "message")
    CALL e % initFatalException(msg = "message")

Plus an assertion exception

    CALL e % initAssertionFailureException(msg,expectedValueObject,observedValueObject,level)

Destruction

    CALL e  %  release()

Setting the infoDictionary

    CALL e  %  setInfoDictionary(infoDictionary)

Getting the infoDictionary

    dict => e % infoDictionary

Getting the name of the exception

    name = e % exceptionName()

Getting the severity level of the exception

    level = e % severity()

Severity levels are FT_ERROR_WARNING or FT_ERROR_FATAL

Printing the exception

    CALL e % printDescription()


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: FT_ERROR_NONE = 0
integer, public, parameter :: FT_ERROR_WARNING = 1
integer, public, parameter :: FT_ERROR_FATAL = 2
integer, public, parameter :: ERROR_MSG_STRING_LENGTH = 132
character(len=21), public, parameter :: FTFatalErrorException = "FTFatalErrorException"
character(len=23), public, parameter :: FTWarningErrorException = "FTWarningErrorException"
character(len=27), public, parameter :: FTAssertionFailureException = "FTAssertionFailureException"

Interfaces

public interface cast

  • public subroutine castToException(obj, cast)

    Cast the base class FTObject to the FTException class

    Arguments

    Type IntentOptional Attributes Name
    class(FTObject), POINTER :: obj
    class(FTException), POINTER :: cast

public interface release

  • public subroutine releaseFTException(self)

    Public, generic name: release(self)

    Call release(self) on an object to release control of an object. If its reference count is zero, then it is deallocated.

    Arguments

    Type IntentOptional Attributes Name
    class(FTException), POINTER :: self

Derived Types

type, public, extends(FTObject) ::  FTException

Type-Bound Procedures

procedure, public :: init => initFTObject
procedure, public :: description => FTObjectDescription
procedure, public, non_overridable :: copy => copyFTObject
procedure, public, non_overridable :: retain => retainFTObject
procedure, public, non_overridable :: isUnreferenced
procedure, public, non_overridable :: refCount
procedure, public :: initFTException
procedure, public :: initWarningException
procedure, public :: initFatalException
procedure, public :: initAssertionFailureException
procedure, public :: destruct => destructException
procedure, public :: setInfoDictionary
procedure, public :: infoDictionary
procedure, public :: exceptionName
procedure, public :: severity
procedure, public :: printDescription => printFTExceptionDescription
procedure, public :: className => exceptionClassName

Functions

public function infoDictionary(self)

Returns the exception's infoDictionary. Does not transfer ownership/reference count is unchanged.

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self

Return Value class(FTDictionary), POINTER

public function exceptionName(self)

Returns the string representing the name set for the exception.

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self

Return Value character(len=ERROR_MSG_STRING_LENGTH)

public function severity(self)

Returns the severity level of the exception.

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self

Return Value integer

public function exceptionFromObject(obj) result(cast)

Arguments

Type IntentOptional Attributes Name
class(FTObject), POINTER :: obj

Return Value class(FTException), POINTER

public function exceptionClassName(self) result(s)

Class name returns a string with the name of the type of the object

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self

Return Value character(len=CLASS_NAME_CHARACTER_LENGTH)


Subroutines

public subroutine initWarningException(self, msg)

A convenience initializer for a warning error that includes the key "message" in the infoDictionary. Use this initializer as an example of how to write one's own exception.

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self
character(len=*) :: msg

public subroutine initFatalException(self, msg)

A convenience initializer for a fatal error that includes the key "message" in the infoDictionary.Use this initializer as an example of how to write one's own exception.

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self
character(len=*) :: msg

public subroutine initFTException(self, severity, exceptionName, infoDictionary)

The main initializer for the class

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self
integer :: severity
character(len=*) :: exceptionName
class(FTDictionary), optional, POINTER :: infoDictionary

public subroutine initAssertionFailureException(self, msg, expectedValueObject, ObservedValueObject, level)

A convenience initializer for an assertion error that includes the keys:

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self
character(len=*) :: msg
class(FTValue), POINTER :: expectedValueObject
class(FTValue), POINTER :: ObservedValueObject
integer :: level

public subroutine destructException(self)

The destructor for the class. Do not call this directly. Call the release() procedure instead

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self

public subroutine releaseFTException(self)

Public, generic name: release(self)

Read more…

Arguments

Type IntentOptional Attributes Name
class(FTException), POINTER :: self

public subroutine setInfoDictionary(self, dict)

Sets and retains the exception infoDictionary

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self
class(FTDictionary), POINTER :: dict

public subroutine releaseMemberDictionary(self)

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self

public subroutine printFTExceptionDescription(self, iUnit)

A basic printing of the exception and the info held in the infoDicitonary.

Arguments

Type IntentOptional Attributes Name
class(FTException) :: self
integer :: iUnit

public subroutine castToException(obj, cast)

Cast the base class FTObject to the FTException class

Arguments

Type IntentOptional Attributes Name
class(FTObject), POINTER :: obj
class(FTException), POINTER :: cast