libyui  3.1.5
YUIException.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YUIException.h
20 
21  Stolen from zypp/libzypp/base/Exception.h
22 
23  Author: Michael Andres <ma@suse.de>
24  Maintainer: Stefan Hundhammer <sh@suse.de>
25 
26 /-*/
27 
28 #ifndef YUIException_h
29 #define YUIException_h
30 
31 
32 #include <cerrno>
33 #include <iostream>
34 #include <stdexcept>
35 
36 #include "YProperty.h"
37 
38 
39 class YWidget;
40 
41 
42 //
43 // Macros for application use
44 //
45 
46 /**
47  * Usage summary:
48  *
49  * Use YUI_THROW to throw exceptions.
50  * Use YUI_CAUGHT If you caught an exceptions in order to handle it.
51  * Use YUI_RETHROW to rethrow a caught exception.
52  *
53  * The use of these macros is not mandatory. but YUI_THROW and YUI_RETHROW will
54  * adjust the code location information stored in the exception. All three
55  * macros will drop a line in the log file.
56  *
57  * 43 try
58  * 44 {
59  * 45 try
60  * 46 {
61  * 47 YUI_THROW( YUIException("Something bad happened.") );
62  * 48 }
63  * 49 catch( YUIException & exception )
64  * 50 {
65  * 51 YUI_RETHROW( exception );
66  * 52 }
67  * 53 }
68  * 54 catch( YUIException & exception )
69  * 55 {
70  * 56 YUI_CAUGHT( exception );
71  * 57 }
72  *
73  * The above produces the following log lines:
74  *
75  * Main.cc(main):47 THROW: Main.cc(main):47: Something bad happened.
76  * Main.cc(main):51 RETHROW: Main.cc(main):47: Something bad happened.
77  * Main.cc(main):56 CAUGHT: Main.cc(main):51: Something bad happened.
78  **/
79 
80 
81 /**
82  * Create YCodeLocation object storing the current location.
83  **/
84 #define YUI_EXCEPTION_CODE_LOCATION YCodeLocation(__FILE__,__FUNCTION__,__LINE__)
85 
86 
87 /**
88  * Drops a log line and throws the YUIException.
89  **/
90 #define YUI_THROW( EXCEPTION ) \
91  _YUI_THROW( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION )
92 
93 /**
94  * Drops a log line telling the YUIException was caught and handled.
95  **/
96 #define YUI_CAUGHT( EXCEPTION ) \
97  _YUI_CAUGHT( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION )
98 
99 
100 /**
101  * Drops a log line and rethrows, updating the YCodeLocation.
102  **/
103 #define YUI_RETHROW( EXCEPTION ) \
104  _YUI_RETHROW( ( EXCEPTION ), YUI_EXCEPTION_CODE_LOCATION )
105 
106 
107 /**
108  * Throw YUIException built from a message string.
109  **/
110 #define YUI_THROW_MSG( EXCEPTION_TYPE, MSG ) \
111  YUI_THROW( EXCEPTION_TYPE( MSG ) )
112 
113 
114 /**
115  * Throw YUIException built from errno.
116  **/
117 #define YUI_THROW_ERRNO( EXCEPTION_TYPE ) \
118  YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( errno ) ) )
119 
120 /**
121  * Throw YUIException built from errno provided as argument.
122  **/
123 #define YUI_THROW_ERRNO1( EXCEPTION_TYPE, ERRNO ) \
124  YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( ERRNO ) ) )
125 
126 /**
127  * Throw YUIException built from errno and a message string.
128  **/
129 #define YUI_THROW_ERRNO_MSG( EXCEPTION_TYPE, MSG) \
130  YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( errno, MSG ) ) )
131 
132 /**
133  * Throw YUIException built from errno provided as argument and a message string.
134  **/
135 #define YUI_THROW_ERRNO_MSG1( EXCEPTION_TYPE, ERRNO,MSG ) \
136  YUI_THROW( EXCEPTION_TYPE( YUIException::strErrno( ERRNO, MSG ) ) )
137 
138 
139 //
140 // Higher-level (UI specific) exception macros
141 //
142 
143 /**
144  * Check if an instance returned by operator new is valid (nonzero).
145  * Throws YUIOutOfMemoryException if it is 0.
146  **/
147 #define YUI_CHECK_NEW( PTR ) \
148  do \
149  { \
150  if ( ! (PTR) ) \
151  { \
152  YUI_THROW( YUIOutOfMemoryException() ); \
153  } \
154  } while( 0 )
155 
156 
157 
158 /**
159  * Check for null pointer.
160  * Throws YUINullPointerException if the pointer is 0.
161  **/
162 #define YUI_CHECK_PTR( PTR ) \
163  do \
164  { \
165  if ( ! (PTR) ) \
166  { \
167  YUI_THROW( YUINullPointerException() ); \
168  } \
169  } while( 0 )
170 
171 
172 /**
173  * Check if a widget pointer is valid.
174  * Throws YUIInvalidWidgetException if it is 0 or invalid (already deleted).
175  **/
176 #define YUI_CHECK_WIDGET( WIDGET ) \
177  do \
178  { \
179  if ( ! (WIDGET) || ! (WIDGET)->isValid() ) \
180  { \
181  YUI_THROW( YUIInvalidWidgetException() ); \
182  } \
183  } while( 0 )
184 
185 
186 /**
187  * Check if an index is in range:
188  * VALID_MIN <= INDEX <= VALID_MAX
189  *
190  * Throws YUIInvalidWidgetException if out of range.
191  **/
192 #define YUI_CHECK_INDEX_MSG( INDEX, VALID_MIN, VALID_MAX, MSG ) \
193  do \
194  { \
195  if ( (INDEX) < (VALID_MIN) || \
196  (INDEX) > (VALID_MAX) ) \
197  { \
198  YUI_THROW( YUIIndexOutOfRangeException( (INDEX), (VALID_MIN), (VALID_MAX), (MSG) ) ); \
199  } \
200  } while( 0 )
201 
202 
203 #define YUI_CHECK_INDEX( INDEX, VALID_MIN, VALID_MAX ) \
204  YUI_CHECK_INDEX_MSG( (INDEX), (VALID_MIN), (VALID_MAX), "")
205 
206 
207 
208 
209 /**
210  * Helper class for UI exceptions: Store _FILE_, _FUNCTION_ and _LINE_.
211  * Construct this using the YUI_EXCEPTION_CODE_LOCATION macro.
212  **/
214 {
215 public:
216  /**
217  * Constructor.
218  * Commonly called using the YUI_EXCEPTION_CODE_LOCATION macro.
219  **/
220  YCodeLocation( const std::string & file_r,
221  const std::string & func_r,
222  int line_r )
223  : _file( file_r )
224  , _func( func_r )
225  , _line( line_r )
226  {}
227 
228  /**
229  * Default constructor.
230  ***/
232  : _line( 0 )
233  {}
234 
235  /**
236  * Returns the source file name where the exception occured.
237  **/
238  std::string file() const { return _file; }
239 
240  /**
241  * Returns the name of the function where the exception occured.
242  **/
243  std::string func() const { return _func; }
244 
245  /**
246  * Returns the source line number where the exception occured.
247  **/
248  int line() const { return _line; }
249 
250  /**
251  * Returns the location in normalized string format.
252  **/
253  std::string asString() const;
254 
255  /**
256  * Stream output
257  **/
258  friend std::ostream & operator<<( std::ostream & str, const YCodeLocation & obj );
259 
260 private:
261  std::string _file;
262  std::string _func;
263  int _line;
264 
265 }; // YCodeLocation
266 
267 
268 /**
269  * YCodeLocation stream output
270  **/
271 std::ostream & operator<<( std::ostream & str, const YCodeLocation & obj );
272 
273 
274 /**
275  * Base class for UI Exceptions.
276  *
277  * Exception offers to store a message string passed to the constructor.
278  * Derived classes may provide additional information.
279  * Overload dumpOn to provide a proper error text.
280  **/
281 class YUIException : public std::exception
282 {
283 public:
284  /**
285  * Default constructor.
286  * Use YUI_THROW to throw exceptions.
287  **/
288  YUIException();
289 
290  /**
291  * Constructor taking a message.
292  * Use YUI_THROW to throw exceptions.
293  **/
294  YUIException( const std::string & msg_r );
295 
296  /**
297  * Destructor.
298  **/
299  virtual ~YUIException() throw();
300 
301  /**
302  * Return YCodeLocation.
303  **/
304  const YCodeLocation & where() const
305  { return _where; }
306 
307  /**
308  * Exchange location on rethrow.
309  **/
310  void relocate( const YCodeLocation & newLocation ) const
311  { _where = newLocation; }
312 
313  /**
314  * Return the message string provided to the constructor.
315  * Note: This is not neccessarily the complete error message.
316  * The whole error message is provided by asString or dumpOn.
317  **/
318  const std::string & msg() const
319  { return _msg; }
320 
321  /**
322  * Set a new message string.
323  **/
324  void setMsg( const std::string & msg )
325  { _msg = msg; }
326 
327  /**
328  * Error message provided by dumpOn as string.
329  **/
330  std::string asString() const;
331 
332  /**
333  * Make a string from errno_r.
334  **/
335  static std::string strErrno( int errno_r );
336 
337  /**
338  * Make a string from errno_r and msg_r.
339  **/
340  static std::string strErrno( int errno_r, const std::string & msg );
341 
342  /**
343  * Drop a log line on throw, catch or rethrow.
344  * Used by YUI_THROW macros.
345  **/
346  static void log( const YUIException & exception,
347  const YCodeLocation & location,
348  const char * const prefix );
349  /**
350  * Return message string.
351  *
352  * Reimplemented from std::exception.
353  **/
354  virtual const char * what() const throw()
355  { return _msg.c_str(); }
356 
357 protected:
358 
359  /**
360  * Overload this to print a proper error message.
361  **/
362  virtual std::ostream & dumpOn( std::ostream & str ) const;
363 
364 
365 private:
366  friend std::ostream & operator<<( std::ostream & str, const YUIException & obj );
367 
368 
369  mutable YCodeLocation _where;
370  std::string _msg;
371 
372  /**
373  * Called by std::ostream & operator<<() .
374  * Prints YCodeLocation and the error message provided by dumpOn.
375  **/
376  std::ostream & dumpError( std::ostream & str ) const;
377 
378 }; // class YUIException
379 
380 
381 /**
382  * YUIException stream output
383  **/
384 std::ostream & operator<<( std::ostream & str, const YUIException & obj );
385 
386 
387 /**
388  * Exception class for generic null pointer exceptions.
389  * When available, a more specialized exception class should be used.
390  **/
392 {
393 public:
395  : YUIException( "Null pointer" )
396  {}
397 
398  virtual ~YUINullPointerException() throw()
399  {}
400 };
401 
402 
403 /**
404  * Exception class for "out of memory".
405  * Typically used if operator new returned 0.
406  **/
408 {
409 public:
411  : YUIException( "Out of memory" )
412  {}
413 
414  virtual ~YUIOutOfMemoryException() throw()
415  {}
416 
417 };
418 
419 /**
420  * Exception class for invalid widgets.
421  * This is typically caused by widget pointers that continue living after the
422  * corresponding widget has already been deleted.
423  **/
425 {
426 public:
428  : YUIException( "Invalid widget" )
429  {}
430 
431  virtual ~YUIInvalidWidgetException() throw()
432  {}
433 };
434 
435 
436 /**
437  * Exception class for "No widget found with that ID".
438  **/
440 {
441 public:
442  YUIWidgetNotFoundException( const std::string & idString )
443  : YUIException( std::string( "No widget with ID " ) + idString )
444  {}
445 
446  virtual ~YUIWidgetNotFoundException() throw()
447  {}
448 };
449 
450 
452 {
453 public:
455  : YUIException( "No dialog existing" )
456  {}
457 
458  virtual ~YUINoDialogException() throw()
459  {}
460 };
461 
462 
464 {
465 public:
467  : YUIException( "Dialog stacking order violated" )
468  {}
469 
470  virtual ~YUIDialogStackingOrderException() throw()
471  {}
472 };
473 
474 
476 {
477 public:
478  YUISyntaxErrorException( const std::string & msg )
479  : YUIException( msg )
480  {}
481 
482  virtual ~YUISyntaxErrorException() throw()
483  {}
484 };
485 
486 
487 /**
488  * Abstract base class for widget property exceptions.
489  **/
491 {
492 protected:
493  YUIPropertyException( const YProperty & prop,
494  YWidget * widget = 0 )
495  : YUIException()
496  , _property( prop )
497  , _widget( widget )
498  {}
499 
500  virtual ~YUIPropertyException() throw()
501  {}
502 
503 public:
504  /**
505  * Returns the property that caused this exception.
506  **/
507  YProperty property() const { return _property; }
508 
509  /**
510  * Returns the corresponding widget or 0 if there was none.
511  **/
512  YWidget * widget() const { return _widget; }
513 
514  /**
515  * Set the corresponding widget.
516  **/
517  void setWidget( YWidget * w ) { _widget = w; }
518 
519 protected:
520 
521  /**
522  * Write proper error message with all relevant data.
523  * Reimplemented from YUIException.
524  **/
525  virtual std::ostream & dumpOn( std::ostream & str ) const = 0;
526 
527 private:
528  YProperty _property;
529  YWidget * _widget;
530 };
531 
532 
533 /**
534  * Exception class for "unknown property name":
535  * The application tried to set (or query) a property that doesn't exist.
536  **/
538 {
539 public:
540  YUIUnknownPropertyException( const std::string & propertyName,
541  YWidget * widget = 0 )
542  : YUIPropertyException( YProperty( propertyName, YUnknownPropertyType ), widget )
543  {}
544 
545  virtual ~YUIUnknownPropertyException() throw()
546  {}
547 
548 protected:
549 
550  /**
551  * Write proper error message with all relevant data.
552  * Reimplemented from YUIException.
553  **/
554  virtual std::ostream & dumpOn( std::ostream & str ) const;
555 };
556 
557 
558 /**
559  * Exception class for "property type mismatch":
560  * The application tried to set a property with a wrong type.
561  **/
563 {
564 public:
565 
567  YPropertyType type,
568  YWidget * widget = 0 )
569  : YUIPropertyException( property, widget )
570  , _type( type )
571  {}
572 
573  virtual ~YUIPropertyTypeMismatchException() throw()
574  {}
575 
576  /**
577  * Return the property type the application tried to set.
578  **/
579  YPropertyType type() const { return _type; }
580 
581 protected:
582 
583  /**
584  * Write proper error message with all relevant data.
585  * Reimplemented from YUIException.
586  **/
587  virtual std::ostream & dumpOn( std::ostream & str ) const;
588 
589 private:
590  YPropertyType _type;
591 };
592 
593 
594 /**
595  * Exception class for attempt to set a read-only property.
596  **/
598 {
599 public:
600 
602  YWidget * widget = 0 )
603  : YUIPropertyException( property, widget )
604  {}
605 
606  virtual ~YUISetReadOnlyPropertyException() throw()
607  {}
608 
609 protected:
610 
611  /**
612  * Write proper error message with all relevant data.
613  * Reimplemented from YUIException.
614  **/
615  virtual std::ostream & dumpOn( std::ostream & str ) const;
616 };
617 
618 
620 {
621 public:
622 
624  YWidget * widget,
625  const std::string & message = "" )
626  : YUIPropertyException( property, widget )
627  { setMsg( message ); }
628 
629  virtual ~YUIBadPropertyArgException() throw()
630  {}
631 
632 protected:
633 
634  /**
635  * Write proper error message with all relevant data.
636  * Reimplemented from YUIException.
637  **/
638  virtual std::ostream & dumpOn( std::ostream & str ) const;
639 };
640 
641 
642 /**
643  * Exception class for "too many children":
644  * Attempt to add a child to a widget class that can't handle children
645  * (YPushButton etc.) or just one child (YFrame, YDialog).
646  **/
647 template<class YWidget> class YUITooManyChildrenException: public YUIException
648 {
649 public:
650 
652  : YUIException( "Too many children" )
653  , _container( container )
654  {}
655 
656  virtual ~YUITooManyChildrenException() throw()
657  {}
658 
659  /**
660  * Returns the container widget that can't handle that many children.
661  **/
662  YWidget * container() const { return _container; }
663 
664 protected:
665 
666  /**
667  * Write proper error message with all relevant data.
668  * Reimplemented from YUIException.
669  **/
670  virtual std::ostream & dumpOn( std::ostream & str ) const
671  {
672  std::string widgetClass =
673  container() ? container()->widgetClass() :
674  "widget";
675 
676  return str << "Too many children for "
677  << widgetClass
678  << std::endl;
679  }
680 
681 private:
682 
683  YWidget * _container;
684 };
685 
686 
687 /**
688  * Exception class for "invalid child". One of:
689  *
690  * - Attempt to remove a child from a children manager that is not in that
691  * manager's children list.
692  *
693  * - Child widget of wrong type added to a container widget, e.g., anything
694  * other than a YPushButton added to a YButtonBox.
695  **/
696 template<class YWidget> class YUIInvalidChildException: public YUIException
697 {
698 public:
699 
701  YWidget * child = 0 )
702  : YUIException( "Invalid child" )
703  , _container( container )
704  , _child( child )
705  {}
706 
707  virtual ~YUIInvalidChildException() throw()
708  {}
709 
710  /**
711  * Returns the container widget whose child should be removed etc.
712  **/
713  YWidget * container() const { return _container; }
714 
715  /**
716  * Returns the child widget.
717  **/
718  YWidget * child() const { return _child; }
719 
720 protected:
721 
722  /**
723  * Write proper error message with all relevant data.
724  * Reimplemented from YUIException.
725  **/
726  virtual std::ostream & dumpOn( std::ostream & str ) const
727  {
728  std::string containerWidgetClass =
729  container() ? container()->widgetClass() :
730  "widget";
731 
732  std::string childWidgetClass =
733  child() ? child()->widgetClass() :
734  "<Null>";
735 
736  return str << childWidgetClass
737  << " is not a child of "
738  << containerWidgetClass
739  << std::endl;
740  }
741 
742 private:
743 
744  YWidget * _container;
745  YWidget * _child;
746 };
747 
748 
749 
750 /**
751  * Exception class for "optional widget not supported".
752  *
753  * Note that applications are supposed to check with
754  * YUI::optionalWidgetFactory()->hasXYWidget() before trying to create such a
755  * widget. This exception is thrown if that check wasn't done, the application
756  * tried to create that kind of widget anyway, but the UI doesn't support that
757  * widget.
758  **/
760 {
761 public:
762 
763  YUIUnsupportedWidgetException( const std::string & widgetType )
764  : YUIException( std::string( "Unsupported optional widget type: " ) + widgetType )
765  {}
766 
767  virtual ~YUIUnsupportedWidgetException() throw()
768  {}
769 };
770 
771 
772 /**
773  * Exception class for "value other than YD_HORIZ or YD_VERT used for
774  * dimension".
775  **/
777 {
778 public:
780  : YUIException( "Invalid dimension (neither YD_HORIZ nor YD_VERT)" )
781  {}
782 
783  virtual ~YUIInvalidDimensionException() throw()
784  {}
785 };
786 
787 
788 /**
789  * Exception class for "index out of range"
790  **/
792 {
793 public:
794  /**
795  * Constructor.
796  *
797  * 'invalidIndex' is the offending index value. It should be between
798  *'validMin' and 'validMax':
799  *
800  * validMin <= index <= validMax
801  **/
803  int validMin,
804  int validMax,
805  const std::string & msg = "" )
806  : YUIException( msg )
807  , _invalidIndex( invalidIndex )
808  , _validMin( validMin )
809  , _validMax( validMax )
810  {}
811 
812  virtual ~YUIIndexOutOfRangeException() throw()
813  {}
814 
815  /**
816  * Return the offending index value.
817  **/
818  int invalidIndex() const { return _invalidIndex; }
819 
820  /**
821  * Return the valid minimum index.
822  **/
823  int validMin() const { return _validMin; }
824 
825  /**
826  * Return the valid maximum index.
827  **/
828  int validMax() const { return _validMax; }
829 
830 protected:
831 
832  /**
833  * Write proper error message with all relevant data.
834  * Reimplemented from YUIException.
835  **/
836  virtual std::ostream & dumpOn( std::ostream & str ) const
837  {
838  std::string prefix = msg();
839 
840  if ( prefix.empty() )
841  prefix = "Index out of range";
842 
843  return str << prefix << ": " << _invalidIndex
844  << " valid: " << _validMin << " .. " << _validMax
845  << std::endl;
846  }
847 
848 private:
849 
850  int _invalidIndex;
851  int _validMin;
852  int _validMax;
853 };
854 
855 
856 /**
857  * Exception class for plugin load failure
858  **/
860 {
861 public:
862  YUIPluginException( const std::string & pluginName )
863  : YUIException( std::string( "Couldn't load plug-in " ) + pluginName )
864  {}
865 
866  virtual ~YUIPluginException() throw()
867  {}
868 };
869 
870 
871 /**
872  * Exception class for UI plugin load failure
873  **/
875 {
876 public:
878  : YUIException( "No $DISPLAY and stdout is not a tty" )
879  {}
880 
881  virtual ~YUICantLoadAnyUIException() throw()
882  {}
883 };
884 
885 
886 /**
887  * Exception class for "wrong button roles in YButtonBox"
888  **/
890 {
891 public:
892 
893  YUIButtonRoleMismatchException( const std::string & msg )
894  : YUIException( msg )
895  {}
896 
897  virtual ~YUIButtonRoleMismatchException() throw()
898  {}
899 };
900 
901 
902 //
903 // Helper templates
904 //
905 
906 
907 /**
908  * Helper for YUI_THROW()
909  **/
910 template<class _Exception>
911 void _YUI_THROW( const _Exception & exception_r, const YCodeLocation & where_r )
912 {
913  exception_r.relocate( where_r );
914  YUIException::log( exception_r, where_r, "THROW: " );
915  throw( exception_r );
916 }
917 
918 
919 /**
920  * Helper for YUI_CAUGHT()
921  **/
922 template<class _Exception>
923 void _YUI_CAUGHT( const _Exception & exception_r, const YCodeLocation & where_r )
924 {
925  YUIException::log( exception_r, where_r, "CAUGHT: " );
926 }
927 
928 
929 /**
930  * Helper for YUI_RETHROW()
931  **/
932 template<class _Exception>
933 void _YUI_RETHROW( const _Exception & exception_r, const YCodeLocation & where_r )
934 {
935  YUIException::log( exception_r, where_r, "RETHROW: " );
936  exception_r.relocate( where_r );
937  throw;
938 }
939 
940 
941 #endif // YUIException_h
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
virtual ~YUIException()
Destructor.
Definition: YUIException.cc:74
std::string asString() const
Returns the location in normalized string format.
Definition: YUIException.cc:41
virtual std::ostream & dumpOn(std::ostream &str) const =0
Write proper error message with all relevant data.
const YCodeLocation & where() const
Return YCodeLocation.
Definition: YUIException.h:304
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YWidget.h:72
Exception class for "index out of range".
Definition: YUIException.h:791
Exception class for attempt to set a read-only property.
Definition: YUIException.h:597
void setMsg(const std::string &msg)
Set a new message string.
Definition: YUIException.h:324
Exception class for "too many children": Attempt to add a child to a widget class that can't handle c...
Definition: YUIException.h:647
int line() const
Returns the source line number where the exception occured.
Definition: YUIException.h:248
const std::string & msg() const
Return the message string provided to the constructor.
Definition: YUIException.h:318
virtual const char * what() const
Return message string.
Definition: YUIException.h:354
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
Definition: YUIException.cc:90
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: YUIException.h:670
void setWidget(YWidget *w)
Set the corresponding widget.
Definition: YUIException.h:517
YCodeLocation(const std::string &file_r, const std::string &func_r, int line_r)
Constructor.
Definition: YUIException.h:220
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: YUIException.h:836
Exception class for "wrong button roles in YButtonBox".
Definition: YUIException.h:889
friend std::ostream & operator<<(std::ostream &str, const YCodeLocation &obj)
Stream output.
Definition: YUIException.cc:56
YWidget * container() const
Returns the container widget that can't handle that many children.
Definition: YUIException.h:662
Exception class for "value other than YD_HORIZ or YD_VERT used for dimension".
Definition: YUIException.h:776
YWidget * widget() const
Returns the corresponding widget or 0 if there was none.
Definition: YUIException.h:512
friend std::ostream & operator<<(std::ostream &str, const YUIException &obj)
YUIException stream output.
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
YUIIndexOutOfRangeException(int invalidIndex, int validMin, int validMax, const std::string &msg="")
Constructor.
Definition: YUIException.h:802
Exception class for invalid widgets.
Definition: YUIException.h:424
Exception class for plugin load failure.
Definition: YUIException.h:859
std::string asString() const
Error message provided by dumpOn as string.
Definition: YUIException.cc:81
Exception class for "out of memory".
Definition: YUIException.h:407
Exception class for "optional widget not supported".
Definition: YUIException.h:759
Exception class for "No widget found with that ID".
Definition: YUIException.h:439
Exception class for "unknown property name": The application tried to set (or query) a property that ...
Definition: YUIException.h:537
YProperty property() const
Returns the property that caused this exception.
Definition: YUIException.h:507
YCodeLocation()
Default constructor.
Definition: YUIException.h:231
YUIException()
Default constructor.
Definition: YUIException.cc:62
std::string func() const
Returns the name of the function where the exception occured.
Definition: YUIException.h:243
Class for widget properties.
Definition: YProperty.h:51
int validMax() const
Return the valid maximum index.
Definition: YUIException.h:828
int validMin() const
Return the valid minimum index.
Definition: YUIException.h:823
Helper class for UI exceptions: Store FILE, FUNCTION and LINE.
Definition: YUIException.h:213
void relocate(const YCodeLocation &newLocation) const
Exchange location on rethrow.
Definition: YUIException.h:310
Exception class for "property type mismatch": The application tried to set a property with a wrong ty...
Definition: YUIException.h:562
YPropertyType type() const
Return the property type the application tried to set.
Definition: YUIException.h:579
static void log(const YUIException &exception, const YCodeLocation &location, const char *const prefix)
Drop a log line on throw, catch or rethrow.
Exception class for generic null pointer exceptions.
Definition: YUIException.h:391
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: YUIException.h:726
int invalidIndex() const
Return the offending index value.
Definition: YUIException.h:818
YWidget * child() const
Returns the child widget.
Definition: YUIException.h:718
Exception class for "invalid child".
Definition: YUIException.h:696
static std::string strErrno(int errno_r)
Make a string from errno_r.
Exception class for UI plugin load failure.
Definition: YUIException.h:874
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Abstract base class for widget property exceptions.
Definition: YUIException.h:490
Abstract base class of all UI widgets.
Definition: YWidget.h:54
Base class for UI Exceptions.
Definition: YUIException.h:281
YWidget * container() const
Returns the container widget whose child should be removed etc.
Definition: YUIException.h:713
std::string file() const
Returns the source file name where the exception occured.
Definition: YUIException.h:238