28 #ifndef YUIException_h 29 #define YUIException_h 36 #include "YProperty.h" 84 #define YUI_EXCEPTION_CODE_LOCATION YCodeLocation(__FILE__,__FUNCTION__,__LINE__) 90 #define YUI_THROW( EXCEPTION ) \ 91 _YUI_THROW( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION ) 96 #define YUI_CAUGHT( EXCEPTION ) \ 97 _YUI_CAUGHT( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION ) 103 #define YUI_RETHROW( EXCEPTION ) \ 104 _YUI_RETHROW( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION ) 110 #define YUI_THROW_MSG( EXCEPTION_TYPE, MSG ) \ 111 YUI_THROW( EXCEPTION_TYPE( MSG ) ) 117 #define YUI_THROW_ERRNO( EXCEPTION_TYPE ) \ 118 YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( errno ) ) ) 123 #define YUI_THROW_ERRNO1( EXCEPTION_TYPE, ERRNO ) \ 124 YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( ERRNO ) ) ) 129 #define YUI_THROW_ERRNO_MSG( EXCEPTION_TYPE, MSG) \ 130 YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( errno, MSG ) ) ) 135 #define YUI_THROW_ERRNO_MSG1( EXCEPTION_TYPE, ERRNO,MSG ) \ 136 YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( ERRNO, MSG ) ) ) 147 #define YUI_CHECK_NEW( PTR ) \ 152 YUI_THROW( YUIOutOfMemoryException() ); \ 162 #define YUI_CHECK_PTR( PTR ) \ 167 YUI_THROW( YUINullPointerException() ); \ 191 #define YUI_CHECK_WIDGET( WIDGET ) \ 194 if ( ! ( static_cast<bool> (WIDGET) ) || \ 195 ! (WIDGET)->isValid() ) \ 197 YUI_THROW( YUIInvalidWidgetException() ); \ 208 #define YUI_CHECK_INDEX_MSG( INDEX, VALID_MIN, VALID_MAX, MSG ) \ 211 if ( (INDEX) < (VALID_MIN) || \ 212 (INDEX) > (VALID_MAX) ) \ 214 YUI_THROW( YUIIndexOutOfRangeException( (INDEX), (VALID_MIN), (VALID_MAX), (MSG) ) ); \ 219 #define YUI_CHECK_INDEX( INDEX, VALID_MIN, VALID_MAX ) \ 220 YUI_CHECK_INDEX_MSG( (INDEX), (VALID_MIN), (VALID_MAX), "") 237 const std::string & func_r,
254 std::string
file()
const {
return _file; }
259 std::string
func()
const {
return _func; }
264 int line()
const {
return _line; }
287 std::ostream & operator<<( std::ostream & str,
const YCodeLocation & obj );
327 { _where = newLocation; }
334 const std::string &
msg()
const 351 static std::string
strErrno(
int errno_r );
356 static std::string
strErrno(
int errno_r,
const std::string &
msg );
364 const char *
const prefix );
370 virtual const char *
what()
const throw()
371 {
return _msg.c_str(); }
378 virtual std::ostream &
dumpOn( std::ostream & str )
const;
392 std::ostream & dumpError( std::ostream & str )
const;
400 std::ostream & operator<<( std::ostream & str,
const YUIException & obj );
459 :
YUIException( std::string(
"No widget with ID " ) + idString )
541 virtual std::ostream &
dumpOn( std::ostream & str )
const = 0;
570 virtual std::ostream &
dumpOn( std::ostream & str )
const;
595 YPropertyType
type()
const {
return _type; }
603 virtual std::ostream &
dumpOn( std::ostream & str )
const;
631 virtual std::ostream &
dumpOn( std::ostream & str )
const;
641 const std::string & message =
"" )
654 virtual std::ostream &
dumpOn( std::ostream & str )
const;
686 virtual std::ostream &
dumpOn( std::ostream & str )
const 688 std::string widgetClass =
692 return str <<
"Too many children for " 742 virtual std::ostream &
dumpOn( std::ostream & str )
const 744 std::string containerWidgetClass =
748 std::string childWidgetClass =
752 return str << childWidgetClass
753 <<
" is not a child of " 754 << containerWidgetClass
780 :
YUIException( std::string(
"Unsupported optional widget type: " ) + widgetType )
796 :
YUIException(
"Invalid dimension (neither YD_HORIZ nor YD_VERT)" )
821 const std::string &
msg =
"" )
852 virtual std::ostream &
dumpOn( std::ostream & str )
const 854 std::string prefix =
msg();
856 if ( prefix.empty() )
857 prefix =
"Index out of range";
859 return str << prefix <<
": " << _invalidIndex
860 <<
" valid: " << _validMin <<
" .. " << _validMax
879 :
YUIException( std::string(
"Couldn't load plug-in " ) + pluginName )
926 template<
class _Exception>
927 void _YUI_THROW(
const _Exception & exception_r,
const YCodeLocation & where_r )
929 exception_r.relocate( where_r );
931 throw( exception_r );
938 template<
class _Exception>
939 void _YUI_CAUGHT(
const _Exception & exception_r,
const YCodeLocation & where_r )
948 template<
class _Exception>
949 void _YUI_RETHROW(
const _Exception & exception_r,
const YCodeLocation & where_r )
952 exception_r.relocate( where_r );
957 #endif // YUIException_h virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.cc:162
YProperty property() const
Definition: YUIException.h:523
virtual ~YUIException()
Definition: YUIException.cc:75
virtual std::ostream & dumpOn(std::ostream &str) const =0
std::string asString() const
Definition: YUIException.cc:82
YPropertyType type() const
Definition: YUIException.h:595
Definition: YUIException.h:807
void relocate(const YCodeLocation &newLocation) const
Definition: YUIException.h:326
Definition: YUIException.h:613
void setMsg(const std::string &msg)
Definition: YUIException.h:340
Definition: YUIException.h:663
YWidget * child() const
Definition: YUIException.h:734
YWidget * container() const
Definition: YUIException.h:678
int line() const
Definition: YUIException.h:264
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.cc:141
std::string asString() const
Definition: YUIException.cc:42
int validMax() const
Definition: YUIException.h:844
void setWidget(YWidget *w)
Definition: YUIException.h:533
YCodeLocation(const std::string &file_r, const std::string &func_r, int line_r)
Definition: YUIException.h:236
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.h:852
static std::string strErrno(int errno_r)
Definition: YUIException.cc:112
friend std::ostream & operator<<(std::ostream &str, const YCodeLocation &obj)
Definition: YUIException.h:792
friend std::ostream & operator<<(std::ostream &str, const YUIException &obj)
YWidget * container() const
Definition: YUIException.h:729
Definition: YUIException.h:467
std::string func() const
Definition: YUIException.h:259
virtual const char * what() const
Definition: YUIException.h:370
std::string file() const
Definition: YUIException.h:254
YUIIndexOutOfRangeException(int invalidIndex, int validMin, int validMax, const std::string &msg="")
Definition: YUIException.h:818
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.h:742
Definition: YUIException.h:491
Definition: YUIException.h:875
int validMin() const
Definition: YUIException.h:839
Definition: YUIException.h:423
Definition: YUIException.h:635
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.cc:181
Definition: YUIException.h:553
YCodeLocation()
Definition: YUIException.h:247
YUIException()
Definition: YUIException.cc:63
Definition: YProperty.h:51
Definition: YUIException.h:229
const std::string & msg() const
Definition: YUIException.h:334
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.cc:197
Definition: YUIException.h:578
static void log(const YUIException &exception, const YCodeLocation &location, const char *const prefix)
Definition: YUIException.cc:128
Definition: YUIException.h:479
Definition: YUIException.h:407
Definition: YUIException.h:712
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.h:686
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: YUIException.cc:91
Definition: YUIException.h:890
Definition: YUIException.h:506
int invalidIndex() const
Definition: YUIException.h:834
const YCodeLocation & where() const
Definition: YUIException.h:320
Definition: YUIException.h:297
YWidget * widget() const
Definition: YUIException.h:528