JAULA::Exception Class Reference
JAULA: Error handling

Base class for error handling exceptions. More...

`#include <jaula_exception.h>`

Inheritance diagram for JAULA::Exception:

## Public Types

enum | ExCode { NO_ERROR , BAD_DATA_TYPE , NAME_DUPLICATED , LEXAN_ERROR , SYNTAX_ERROR }
| Enumeration of available error codes. More...

## Public Member Functions

void | addOrigin (std::string const &origin)
| Attachs a new origin after the existing ones.
void | display (std::ostream &ostr) const
| Represents the instance in a stream.
| Exception (Exception const &orig)
| Copy constructor.
| Exception (ExCode code=NO_ERROR, std::string const &detail="", std::string const &action="", std::string const &origin="")
| Constructor.
std::string const & | getAction (void) const
| Retrieves the action that caused the exception.
ExCode | getCode (void) const
| Retrieves the error code for the exception.
virtual std::string const & | getDetail (void) const
| Retrieves the detailed description for the exception.
std::string const & | getOrigin (void) const
| Retrieves the method being run when the exception arose.
Exception & | operator= (Exception const &orig)
| Assignment operator.
void | setAction (std::string const &action)
| Establishes the action that caused the exception.
void | setDetail (std::string const &detail)
| Establishes the description for the exception.
void | setOrigin (std::string const &origin)
| Establishes the method being run when the exception arose.
virtual | ~Exception ()
| Destructor.

## Protected Member Functions

void | setCode (ExCode code)
| Establishes the error code for the exception.

## Private Attributes

std::string | action_
| Container action causing the exception.
ExCode | code_
| Container for error code.
std::string | detail_
| Container for exception textual detail.
std::string | origin_
| Container for where the exception was detected.

## Detailed Description

Base class for error handling exceptions.

  This class is the base for all the exceptions thrown by the methods defined in this library.

Author
  Kombo Morongo moron.nosp@m.go66.nosp@m.6@gma.nosp@m.il.c.nosp@m.om

## Member Enumeration Documentation

## ExCode

enum JAULA::Exception::ExCode

Enumeration of available error codes.

Enumerator
NO_ERROR | No Error detected The data provided for a method is from a wrong type
BAD_DATA_TYPE | Name repeated for an object property
NAME_DUPLICATED | Error detected in the lexical analysis phase
LEXAN_ERROR | Error detected in the syntactic analysis phase

## Constructor & Destructor Documentation

## Exception() [1/2]

JAULA::Exception::Exception | ( | ExCode | code = NO_ERROR,
|  | std::string const & | detail = "",
|  | std::string const & | action = "",
|  | std::string const & | origin = "" )

Constructor.

Parameters

  code | Code for the exception as defined in ExCode
  detail | detailed description about the exception which made execution fail.
  action | action being performed when the exception arose.
  origin | Name of the method (and others methods that have called this) by the time the exception arose.

Description
  This method construct a new exception instance detailing each available property.

References action_, code_, detail_, and origin_.

Referenced by JAULA::Bad_Data_Type::Bad_Data_Type(), Exception(), JAULA::Lexan_Error::Lexan_Error(), JAULA::Name_Duplicated::Name_Duplicated(), JAULA::No_Error::No_Error(), operator=(), and JAULA::Syntax_Error::Syntax_Error().

## Exception() [2/2]

JAULA::Exception::Exception | ( | Exception const & | orig | ) |

Copy constructor.

Parameters

  orig | Original instance to copy

Description
  Creates a new instance copying the contents from another

References action_, code_, detail_, Exception(), getAction(), getCode(), getDetail(), getOrigin(), and origin_.

## ~Exception()

JAULA::Exception::~Exception | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## addOrigin()

void JAULA::Exception::addOrigin | ( | std::string const & | origin | ) |

Attachs a new origin after the existing ones.

Parameters

  origin | Name of the method to add

Description
  Adds the name of a method who is supposed to be the next method in the calling stack from where the exception occured so a basic trace can be performed.

References origin_.

Referenced by JAULA::Value::duplicate(), JAULA::Parser::Value_Parser::EOFError(), JAULA::Value::operator=(), JAULA::Parser::parseStream(), JAULA::Parser::Value_Parser::parseValue(), JAULA::Value_Array::set(), JAULA::Value_Boolean::set(), JAULA::Value_Null::set(), JAULA::Value_Number::set(), JAULA::Value_Number_Int::set(), JAULA::Value_Object::set(), and JAULA::Value_String::set().

## display()

void JAULA::Exception::display | ( | std::ostream & | ostr | ) | const

Represents the instance in a stream.

Parameters

  ostr | Stream where the instance is to be displayed.

Description
  Puts a text representation of the instance contents in a stream.

References action_, BAD_DATA_TYPE, code_, detail_, LEXAN_ERROR, NAME_DUPLICATED, NO_ERROR, and origin_.

Referenced by operator<<().

## getAction()

std::string const & JAULA::Exception::getAction | ( | void |  | ) | const

Retrieves the action that caused the exception.

References action_.

Referenced by Exception(), and operator=().

## getCode()

Exception::ExCode JAULA::Exception::getCode | ( | void |  | ) | const

Retrieves the error code for the exception.

References code_.

Referenced by Exception(), and operator=().

## getDetail()

std::string const & JAULA::Exception::getDetail | ( | void |  | ) | const

virtual

Retrieves the detailed description for the exception.

Note
  This method has been declared as virtual so it can be overrwritten to generate automatic detailed descriptions for specific (derived) exception types.

Reimplemented in JAULA::Name_Duplicated.

References detail_.

Referenced by Exception(), and operator=().

## getOrigin()

std::string const & JAULA::Exception::getOrigin | ( | void |  | ) | const

Retrieves the method being run when the exception arose.

Description
  Retrieves the method being run when the exception arose and the methods that called it if available.

References origin_.

Referenced by Exception(), and operator=().

## operator=()

Exception & JAULA::Exception::operator= | ( | Exception const & | orig | ) |

Assignment operator.

Parameters

  orig | Original instance to copy

Returns
  a reference to the destination instance

Description
  Copies the contents of the original instance in the destination.

Note
  This method controls if destination and origin instances are the same so there is no trouble in a = a asignments.

References action_, code_, detail_, Exception(), getAction(), getCode(), getDetail(), getOrigin(), and origin_.

Referenced by JAULA::Bad_Data_Type::operator=(), JAULA::Lexan_Error::operator=(), JAULA::Name_Duplicated::operator=(), JAULA::No_Error::operator=(), and JAULA::Syntax_Error::operator=().

## setAction()

void JAULA::Exception::setAction | ( | std::string const & | action | ) |

Establishes the action that caused the exception.

Parameters

  action | action being performed when the exception arose.

References action_.

## setCode()

void JAULA::Exception::setCode | ( | ExCode | code | ) |

protected

Establishes the error code for the exception.

Parameters

  code | Code for the exception as defined in ExCode

References code_.

## setDetail()

void JAULA::Exception::setDetail | ( | std::string const & | detail | ) |

Establishes the description for the exception.

Parameters

  detail | detailed description about the exception which made execution fail.

References detail_.

## setOrigin()

void JAULA::Exception::setOrigin | ( | std::string const & | origin | ) |

Establishes the method being run when the exception arose.

Parameters

  origin | Name of the method (and others methods that have called this) by the time the exception arose.

References origin_.

## Field Documentation

## action_

std::string JAULA::Exception::action_

private

Container action causing the exception.

Referenced by display(), Exception(), Exception(), getAction(), operator=(), and setAction().

## code_

ExCode JAULA::Exception::code_

private

Container for error code.

Referenced by display(), Exception(), Exception(), getCode(), operator=(), and setCode().

## detail_

std::string JAULA::Exception::detail_

private

Container for exception textual detail.

Referenced by display(), Exception(), Exception(), getDetail(), operator=(), and setDetail().

## origin_

std::string JAULA::Exception::origin_

private

Container for where the exception was detected.

Referenced by addOrigin(), display(), Exception(), Exception(), getOrigin(), operator=(), and setOrigin().

The documentation for this class was generated from the following files:

- jaula_exception.h
- jaula_exception.cc

Back to JAULA Project Documentation Page.

Go to JAULA Project Home Page.

Copyright (c) 2007, 2008, 2009 Kombo Morongo.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

SourceForge.net