alaCarte Maps
Renderer for OpenStreetMap tiles
exceptions.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef EXCEPTIONS_HPP
23 #define EXCEPTIONS_HPP
24 /*
25  * =====================================================================================
26  *
27  * Filename: exceptions.hpp
28  *
29  * Description: New exceptions are defined here.
30  *
31  * =====================================================================================
32  */
33 
34 #include "settings.hpp"
35 
36 class ParserLogger;
37 
38 namespace excp {
39 
41  typedef boost::error_info<struct TagWhatInfo, string> InfoWhat;
43  typedef boost::error_info<struct TagFileName, string> InfoFileName;
45  typedef boost::error_info<struct TagXmlEntityName, string> InfoXmlEntityName;
47  typedef boost::error_info<struct TagBadSourceValue, string> InfoBadSourceValue;
49  typedef boost::error_info<struct TagUnresolvableId, long> InfoUnresolvableId;
51  typedef boost::error_info<struct TagFailureLine, int> InfoFailureLine;
53  typedef boost::error_info<struct TagFailureColumn, int> InfoFailureColumn;
55  typedef boost::error_info<struct TagFailureLineContent, string> InfoFailureLineContent;
57  typedef boost::error_info<struct TagParserLogger, shared_ptr<ParserLogger> > InfoParserLogger;
58 
60  struct ExceptionBase : public boost::exception, std::exception
61  {
62  virtual const char* what() const throw()
63  {
64  if(string const* info = boost::get_error_info<InfoWhat>(*this))
65  return info->c_str();
66  return std::exception::what();
67  }
68  };
69 
75  struct FileNotWritable : public ExceptionBase {};
77  struct InputFormatException : public ExceptionBase {};
79  struct BadOsmIdException : public ExceptionBase {};
85  struct ParseException : public ExceptionBase {};
87  struct TimeoutException : public ExceptionBase {};
88 
89 
90 
91  template<typename Info>
92  struct ErrorOut
93  {
94  typedef typename boost::exception_detail::get_error_info_return_type<boost::exception,typename Info::value_type>::type value_type;
95 
96 
97  ErrorOut(boost::exception& e, const string& fallbackInfo = "'unknown'")
98  : fallbackInfo(fallbackInfo)
99  , value(boost::get_error_info<Info>(e))
100  {
101  }
102 
103  string fallbackInfo;
104  value_type value;
105  };
106 
107  template<typename Stream, typename Info>
108  std::basic_ostream<Stream>& operator <<(std::basic_ostream<Stream>& os, const ErrorOut<Info>& info)
109  {
110  if(info.value)
111  {
112  os << *info.value;
113  } else {
114  os << info.fallbackInfo;
115  }
116 
117  return os;
118  }
119 }
120 
121 
122 
123 
124 #endif
Thrown if no more time is left.
Definition: exceptions.hpp:87
Thrown if an unknown image format is requested.
Definition: exceptions.hpp:83
virtual const char * what() const
Definition: exceptions.hpp:62
boost::exception_detail::get_error_info_return_type< boost::exception, typename Info::value_type >::type value_type
Definition: exceptions.hpp:94
Thrown if the parsing fails.
Definition: exceptions.hpp:85
boost::error_info< struct TagXmlEntityName, string > InfoXmlEntityName
Use this this to specify the exception related xml entity.
Definition: exceptions.hpp:45
Thrown if an osm id was not specified before resolving.
Definition: exceptions.hpp:79
boost::error_info< struct TagParserLogger, shared_ptr< ParserLogger > > InfoParserLogger
Contains the logger used while parsing.
Definition: exceptions.hpp:57
value_type value
Definition: exceptions.hpp:104
boost::error_info< struct TagBadSourceValue, string > InfoBadSourceValue
String representation of a bad source value.
Definition: exceptions.hpp:47
Thrown if input was not in the right format.
Definition: exceptions.hpp:77
string fallbackInfo
Definition: exceptions.hpp:103
boost::error_info< struct TagWhatInfo, string > InfoWhat
Use this info to give an what msg to the exception.
Definition: exceptions.hpp:41
boost::error_info< struct TagFailureLine, int > InfoFailureLine
Specifies the Line in the file where the failure appeared.
Definition: exceptions.hpp:51
boost::error_info< struct TagFailureLineContent, string > InfoFailureLineContent
Contains the content of the line where a failure appeared.
Definition: exceptions.hpp:55
boost::error_info< struct TagUnresolvableId, long > InfoUnresolvableId
Specifies the id, which was not resolvable.
Definition: exceptions.hpp:49
Thrown if a file was not found.
Definition: exceptions.hpp:73
boost::error_info< struct TagFailureColumn, int > InfoFailureColumn
Specifies the Column in the Line in the file where the failure appeared.
Definition: exceptions.hpp:53
ErrorOut(boost::exception &e, const string &fallbackInfo="'unknown'")
Definition: exceptions.hpp:97
Thrown if URL is not in SlippyMap-URL-Format.
Definition: exceptions.hpp:81
Thrown if a file was not writeable.
Definition: exceptions.hpp:75
Base of most exceptions thrown by alacarte.
Definition: exceptions.hpp:60
boost::error_info< struct TagFileName, string > InfoFileName
Use this to inform about a file name.
Definition: exceptions.hpp:43
Thrown on a point where implementation is missing.
Definition: exceptions.hpp:71