##

Exception.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* 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.
*
*/
/*
* Author: Nathan Koenig
* Date: 07 May 2007
*/
#ifndef _GAZEBO_EXCEPTION_HH_
#define _GAZEBO_EXCEPTION_HH_
#include <iostream>
#include <sstream>
#include <string>
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
#define gzthrow(msg) {std::ostringstream throwStream;\
throwStream << msg << std::endl << std::flush;\
throw gazebo::common::Exception(__FILE__, __LINE__, throwStream.str()); }
class GZ_COMMON_VISIBLE Exception
{
public: Exception();
public: Exception(const char *_file,
int _line,
std::string _msg);
public: virtual ~Exception();
public: std::string GetErrorFile() const;
public: std::string GetErrorStr() const;
public: void Print() const;
private: std::string file;
private: int line;
private: std::string str;
public: friend std::ostream &operator<<(std::ostream &_out,
const gazebo::common::Exception &_err)
{
return _out << _err.GetErrorStr();
}
};
class GZ_COMMON_VISIBLE InternalError : public Exception
{
public: InternalError();
public: InternalError(const char *_file, int _line,
const std::string &_msg);
public: virtual ~InternalError();
};
class GZ_COMMON_VISIBLE AssertionInternalError : public InternalError
{
public: AssertionInternalError(const char *_file,
int _line,
const std::string &_expr,
const std::string &_function,
const std::string &_msg = "");
public: virtual ~AssertionInternalError();
};
}
}
#endif
gazebo::common::AssertionInternalError::~AssertionInternalError
virtual ~AssertionInternalError()
Destructor.
gazebo::common::Exception
Class for generating exceptions.
Definition: Exception.hh:45
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Exception::Exception
Exception()
Constructor.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::Exception::Print
void Print() const
Print the exception to std out.
gazebo::common::Exception::~Exception
virtual ~Exception()
Destructor.
system.hh
gazebo::common::Exception::GetErrorFile
std::string GetErrorFile() const
Return the error function.
gazebo::common::AssertionInternalError::AssertionInternalError
AssertionInternalError(const char *_file, int _line, const std::string &_expr, const std::string &_function, const std::string &_msg="")
Constructor for assertions.
gazebo::common::InternalError::InternalError
InternalError()
Constructor.
gazebo::common::InternalError::~InternalError
virtual ~InternalError()
Destructor.
gazebo::common::Exception::GetErrorStr
std::string GetErrorStr() const
Return the error string.
gazebo::common::InternalError
Class for generating Internal Gazebo Errors: those errors which should never happend and represent pr...
Definition: Exception.hh:95
gazebo::common::Exception::operator<<
friend std::ostream & operator<<(std::ostream &_out, const gazebo::common::Exception &_err)
stream insertion operator for Gazebo Error
Definition: Exception.hh:84
gazebo::common::AssertionInternalError
Class for generating Exceptions which come from gazebo assertions. They include information about the...
Definition: Exception.hh:116