exception.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 
00031 /************************************************************ 
00032  * Namespace and includes
00033  ************************************************************/
00034 
00035 #ifndef POSE_GRAPH_EXCEPTION_H
00036 #define POSE_GRAPH_EXCEPTION_H
00037 
00038 #include <pose_graph/pose_graph.h>
00039 #include <boost/format.hpp>
00040 #include <stdexcept>
00041 #include <string>
00042 
00043 namespace pose_graph
00044 {
00045 
00046 using boost::format;
00047 using std::string;
00048 
00049 
00051 class PoseGraphException: public std::logic_error
00052 {
00053 public:
00054   PoseGraphException (const format& error_string) : std::logic_error(error_string.str()) {};
00055   PoseGraphException (const char* str) : std::logic_error(str) {};
00056 };
00057 
00058 
00059 
00061 struct UnknownNodeIdException: public PoseGraphException
00062 {
00063   UnknownNodeIdException (const NodeId id): 
00064     PoseGraphException(format("Unknown node id %1%") % id), id(id) {}
00065   const NodeId id;
00066 };
00067 
00069 struct UnknownEdgeIdException: public PoseGraphException
00070 {
00071   UnknownEdgeIdException (const EdgeId id): 
00072     PoseGraphException(format("Unknown edge id %1%") % id), id(id) {}
00073   const EdgeId id;
00074 };
00075 
00076 
00078 struct DuplicateNodeIdException: public PoseGraphException
00079 {
00080   DuplicateNodeIdException (const NodeId id):
00081     PoseGraphException(format("Node %1% already exists") % id), id(id) {}
00082   const NodeId id;
00083 };
00084 
00085 
00087 struct DuplicateEdgeIdException: public PoseGraphException
00088 {
00089   DuplicateEdgeIdException (const EdgeId id):
00090     PoseGraphException(format("Edge %1% already exists") % id), id(id) {}
00091   const EdgeId id;
00092 };
00093 
00094 
00096 struct FileOpenException: public PoseGraphException
00097 {
00098   FileOpenException (const string& filename):
00099     PoseGraphException(format("Failed to open file %1%") % filename) {}
00100 };
00101 
00103 struct FileFormatException: public PoseGraphException
00104 {
00105   FileFormatException (const string& filename): 
00106     PoseGraphException(format("%1% is not a validly formatted pose graph file") % filename) {}
00107 };
00108 
00110 struct UnknownTopicException: public PoseGraphException
00111 {
00112   UnknownTopicException (const string& topic): 
00113     PoseGraphException(format("%1% is not a known topic in this pose graph") % topic) {}
00114 };
00115 
00117 struct NonexistentParamException: public PoseGraphException
00118 {
00119   NonexistentParamException (const string& name) :
00120     PoseGraphException(format ("Ros parameter %1% was not set") % name) {}
00121 };
00122 
00123 
00125 struct DisconnectedNodesException: public PoseGraphException
00126 {
00127   DisconnectedNodesException (const NodeId n1, const NodeId n2) : 
00128     PoseGraphException (format ("No path in graph between %1% and %2%") % n1 % n2) {}
00129 };
00130 
00132 struct GraphOptimizationException: public PoseGraphException
00133 {
00134   GraphOptimizationException (const PoseGraph& g, const double error, const double tol) :
00135     PoseGraphException (format ("When optimizing graph with %1% nodes and %2% edges, final error was %3% > %4%")
00136                         % g.allNodes().size() % g.allEdges().size() % error % tol)
00137   {}
00138 };      
00139 
00140 
00141 } // namespace
00142 
00143 #endif // POSE_GRAPH_EXCEPTION_H


pose_graph
Author(s): Bhaskara Marthi
autogenerated on Tue Jan 7 2014 11:17:15