libyui  3.3.1
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  * Explicitly casting the memory-address stored in the given pointer to
177  * a boolean-type for null-pointer-checks is needed for GCC >= 6, because
178  * it introduces new optimizations to remove null-pointer-checks for 'this'.
179  *
180  * Not explicitly casting the pointer's memory-address, will cause the
181  * compilation to fail with an error, when using this macro in YDialog:
182  *
183  * …/src/YDialog.cc: In member function 'bool YDialog::destroy(bool)':
184  * …/src/YDialog.cc:254:24: error:
185  * nonnull argument 'this' compared to NULL [-Werror=nonnull-compare]
186  * YUI_CHECK_WIDGET( this );
187  * ~~~~~~~~~^~~~~~
188  *
189  * See: https://gcc.gnu.org/gcc-6/porting_to.html
190  **/
191 #define YUI_CHECK_WIDGET( WIDGET ) \
192  do \
193  { \
194  if ( ! ( static_cast<bool> (WIDGET) ) || \
195  ! (WIDGET)->isValid() ) \
196  { \
197  YUI_THROW( YUIInvalidWidgetException() ); \
198  } \
199  } while( 0 )
200 
201 
202 /**
203  * Check if an index is in range:
204  * VALID_MIN <= INDEX <= VALID_MAX
205  *
206  * Throws YUIInvalidWidgetException if out of range.
207  **/
208 #define YUI_CHECK_INDEX_MSG( INDEX, VALID_MIN, VALID_MAX, MSG ) \
209  do \
210  { \
211  if ( (INDEX) < (VALID_MIN) || \
212  (INDEX) > (VALID_MAX) ) \
213  { \
214  YUI_THROW( YUIIndexOutOfRangeException( (INDEX), (VALID_MIN), (VALID_MAX), (MSG) ) ); \
215  } \
216  } while( 0 )
217 
218 
219 #define YUI_CHECK_INDEX( INDEX, VALID_MIN, VALID_MAX ) \
220  YUI_CHECK_INDEX_MSG( (INDEX), (VALID_MIN), (VALID_MAX), "")
221 
222 
223 
224 
225 /**
226  * Helper class for UI exceptions: Store _FILE_, _FUNCTION_ and _LINE_.
227  * Construct this using the YUI_EXCEPTION_CODE_LOCATION macro.
228  **/
230 {
231 public:
232  /**
233  * Constructor.
234  * Commonly called using the YUI_EXCEPTION_CODE_LOCATION macro.
235  **/
236  YCodeLocation( const std::string & file_r,
237  const std::string & func_r,
238  int line_r )
239  : _file( file_r )
240  , _func( func_r )
241  , _line( line_r )
242  {}
243 
244  /**
245  * Default constructor.
246  ***/
248  : _line( 0 )
249  {}
250 
251  /**
252  * Returns the source file name where the exception occured.
253  **/
254  std::string file() const { return _file; }
255 
256  /**
257  * Returns the name of the function where the exception occured.
258  **/
259  std::string func() const { return _func; }
260 
261  /**
262  * Returns the source line number where the exception occured.
263  **/
264  int line() const { return _line; }
265 
266  /**
267  * Returns the location in normalized string format.
268  **/
269  std::string asString() const;
270 
271  /**
272  * Stream output
273  **/
274  friend std::ostream & operator<<( std::ostream & str, const YCodeLocation & obj );
275 
276 private:
277  std::string _file;
278  std::string _func;
279  int _line;
280 
281 }; // YCodeLocation
282 
283 
284 /**
285  * YCodeLocation stream output
286  **/
287 std::ostream & operator<<( std::ostream & str, const YCodeLocation & obj );
288 
289 
290 /**
291  * Base class for UI Exceptions.
292  *
293  * Exception offers to store a message string passed to the constructor.
294  * Derived classes may provide additional information.
295  * Overload dumpOn to provide a proper error text.
296  **/
297 class YUIException : public std::exception
298 {
299 public:
300  /**
301  * Default constructor.
302  * Use YUI_THROW to throw exceptions.
303  **/
304  YUIException();
305 
306  /**
307  * Constructor taking a message.
308  * Use YUI_THROW to throw exceptions.
309  **/
310  YUIException( const std::string & msg_r );
311 
312  /**
313  * Destructor.
314  **/
315  virtual ~YUIException() throw();
316 
317  /**
318  * Return YCodeLocation.
319  **/
320  const YCodeLocation & where() const
321  { return _where; }
322 
323  /**
324  * Exchange location on rethrow.
325  **/
326  void relocate( const YCodeLocation & newLocation ) const
327  { _where = newLocation; }
328 
329  /**
330  * Return the message string provided to the constructor.
331  * Note: This is not neccessarily the complete error message.
332  * The whole error message is provided by asString or dumpOn.
333  **/
334  const std::string & msg() const
335  { return _msg; }
336 
337  /**
338  * Set a new message string.
339  **/
340  void setMsg( const std::string & msg )
341  { _msg = msg; }
342 
343  /**
344  * Error message provided by dumpOn as string.
345  **/
346  std::string asString() const;
347 
348  /**
349  * Make a string from errno_r.
350  **/
351  static std::string strErrno( int errno_r );
352 
353  /**
354  * Make a string from errno_r and msg_r.
355  **/
356  static std::string strErrno( int errno_r, const std::string & msg );
357 
358  /**
359  * Drop a log line on throw, catch or rethrow.
360  * Used by YUI_THROW macros.
361  **/
362  static void log( const YUIException & exception,
363  const YCodeLocation & location,
364  const char * const prefix );
365  /**
366  * Return message string.
367  *
368  * Reimplemented from std::exception.
369  **/
370  virtual const char * what() const throw()
371  { return _msg.c_str(); }
372 
373 protected:
374 
375  /**
376  * Overload this to print a proper error message.
377  **/
378  virtual std::ostream & dumpOn( std::ostream & str ) const;
379 
380 
381 private:
382  friend std::ostream & operator<<( std::ostream & str, const YUIException & obj );
383 
384 
385  mutable YCodeLocation _where;
386  std::string _msg;
387 
388  /**
389  * Called by std::ostream & operator<<() .
390  * Prints YCodeLocation and the error message provided by dumpOn.
391  **/
392  std::ostream & dumpError( std::ostream & str ) const;
393 
394 }; // class YUIException
395 
396 
397 /**
398  * YUIException stream output
399  **/
400 std::ostream & operator<<( std::ostream & str, const YUIException & obj );
401 
402 
403 /**
404  * Exception class for generic null pointer exceptions.
405  * When available, a more specialized exception class should be used.
406  **/
408 {
409 public:
411  : YUIException( "Null pointer" )
412  {}
413 
414  virtual ~YUINullPointerException() throw()
415  {}
416 };
417 
418 
419 /**
420  * Exception class for "out of memory".
421  * Typically used if operator new returned 0.
422  **/
424 {
425 public:
427  : YUIException( "Out of memory" )
428  {}
429 
430  virtual ~YUIOutOfMemoryException() throw()
431  {}
432 
433 };
434 
435 /**
436  * Exception class for invalid widgets.
437  * This is typically caused by widget pointers that continue living after the
438  * corresponding widget has already been deleted.
439  **/
441 {
442 public:
444  : YUIException( "Invalid widget" )
445  {}
446 
447  virtual ~YUIInvalidWidgetException() throw()
448  {}
449 };
450 
451 
452 /**
453  * Exception class for "No widget found with that ID".
454  **/
456 {
457 public:
458  YUIWidgetNotFoundException( const std::string & idString )
459  : YUIException( std::string( "No widget with ID " ) + idString )
460  {}
461 
462  virtual ~YUIWidgetNotFoundException() throw()
463  {}
464 };
465 
466 
468 {
469 public:
471  : YUIException( "No dialog existing" )
472  {}
473 
474  virtual ~YUINoDialogException() throw()
475  {}
476 };
477 
478 
480 {
481 public:
483  : YUIException( "Dialog stacking order violated" )
484  {}
485 
486  virtual ~YUIDialogStackingOrderException() throw()
487  {}
488 };
489 
490 
492 {
493 public:
494  YUISyntaxErrorException( const std::string & msg )
495  : YUIException( msg )
496  {}
497 
498  virtual ~YUISyntaxErrorException() throw()
499  {}
500 };
501 
502 
503 /**
504  * Abstract base class for widget property exceptions.
505  **/
507 {
508 protected:
509  YUIPropertyException( const YProperty & prop,
510  YWidget * widget = 0 )
511  : YUIException()
512  , _property( prop )
513  , _widget( widget )
514  {}
515 
516  virtual ~YUIPropertyException() throw()
517  {}
518 
519 public:
520  /**
521  * Returns the property that caused this exception.
522  **/
523  YProperty property() const { return _property; }
524 
525  /**
526  * Returns the corresponding widget or 0 if there was none.
527  **/
528  YWidget * widget() const { return _widget; }
529 
530  /**
531  * Set the corresponding widget.
532  **/
533  void setWidget( YWidget * w ) { _widget = w; }
534 
535 protected:
536 
537  /**
538  * Write proper error message with all relevant data.
539  * Reimplemented from YUIException.
540  **/
541  virtual std::ostream & dumpOn( std::ostream & str ) const = 0;
542 
543 private:
544  YProperty _property;
545  YWidget * _widget;
546 };
547 
548 
549 /**
550  * Exception class for "unknown property name":
551  * The application tried to set (or query) a property that doesn't exist.
552  **/
554 {
555 public:
556  YUIUnknownPropertyException( const std::string & propertyName,
557  YWidget * widget = 0 )
558  : YUIPropertyException( YProperty( propertyName, YUnknownPropertyType ), widget )
559  {}
560 
561  virtual ~YUIUnknownPropertyException() throw()
562  {}
563 
564 protected:
565 
566  /**
567  * Write proper error message with all relevant data.
568  * Reimplemented from YUIException.
569  **/
570  virtual std::ostream & dumpOn( std::ostream & str ) const;
571 };
572 
573 
574 /**
575  * Exception class for "property type mismatch":
576  * The application tried to set a property with a wrong type.
577  **/
579 {
580 public:
581 
583  YPropertyType type,
584  YWidget * widget = 0 )
585  : YUIPropertyException( property, widget )
586  , _type( type )
587  {}
588 
589  virtual ~YUIPropertyTypeMismatchException() throw()
590  {}
591 
592  /**
593  * Return the property type the application tried to set.
594  **/
595  YPropertyType type() const { return _type; }
596 
597 protected:
598 
599  /**
600  * Write proper error message with all relevant data.
601  * Reimplemented from YUIException.
602  **/
603  virtual std::ostream & dumpOn( std::ostream & str ) const;
604 
605 private:
606  YPropertyType _type;
607 };
608 
609 
610 /**
611  * Exception class for attempt to set a read-only property.
612  **/
614 {
615 public:
616 
617  YUISetReadOnlyPropertyException( const YProperty & property,
618  YWidget * widget = 0 )
619  : YUIPropertyException( property, widget )
620  {}
621 
622  virtual ~YUISetReadOnlyPropertyException() throw()
623  {}
624 
625 protected:
626 
627  /**
628  * Write proper error message with all relevant data.
629  * Reimplemented from YUIException.
630  **/
631  virtual std::ostream & dumpOn( std::ostream & str ) const;
632 };
633 
634 
636 {
637 public:
638 
639  YUIBadPropertyArgException( const YProperty & property,
640  YWidget * widget,
641  const std::string & message = "" )
642  : YUIPropertyException( property, widget )
643  { setMsg( message ); }
644 
645  virtual ~YUIBadPropertyArgException() throw()
646  {}
647 
648 protected:
649 
650  /**
651  * Write proper error message with all relevant data.
652  * Reimplemented from YUIException.
653  **/
654  virtual std::ostream & dumpOn( std::ostream & str ) const;
655 };
656 
657 
658 /**
659  * Exception class for "too many children":
660  * Attempt to add a child to a widget class that can't handle children
661  * (YPushButton etc.) or just one child (YFrame, YDialog).
662  **/
663 template<class YWidget> class YUITooManyChildrenException: public YUIException
664 {
665 public:
666 
667  YUITooManyChildrenException( YWidget * container )
668  : YUIException( "Too many children" )
669  , _container( container )
670  {}
671 
672  virtual ~YUITooManyChildrenException() throw()
673  {}
674 
675  /**
676  * Returns the container widget that can't handle that many children.
677  **/
678  YWidget * container() const { return _container; }
679 
680 protected:
681 
682  /**
683  * Write proper error message with all relevant data.
684  * Reimplemented from YUIException.
685  **/
686  virtual std::ostream & dumpOn( std::ostream & str ) const
687  {
688  std::string widgetClass =
689  container() ? container()->widgetClass() :
690  "widget";
691 
692  return str << "Too many children for "
693  << widgetClass
694  << std::endl;
695  }
696 
697 private:
698 
699  YWidget * _container;
700 };
701 
702 
703 /**
704  * Exception class for "invalid child". One of:
705  *
706  * - Attempt to remove a child from a children manager that is not in that
707  * manager's children list.
708  *
709  * - Child widget of wrong type added to a container widget, e.g., anything
710  * other than a YPushButton added to a YButtonBox.
711  **/
712 template<class YWidget> class YUIInvalidChildException: public YUIException
713 {
714 public:
715 
716  YUIInvalidChildException( YWidget * container,
717  YWidget * child = 0 )
718  : YUIException( "Invalid child" )
719  , _container( container )
720  , _child( child )
721  {}
722 
723  virtual ~YUIInvalidChildException() throw()
724  {}
725 
726  /**
727  * Returns the container widget whose child should be removed etc.
728  **/
729  YWidget * container() const { return _container; }
730 
731  /**
732  * Returns the child widget.
733  **/
734  YWidget * child() const { return _child; }
735 
736 protected:
737 
738  /**
739  * Write proper error message with all relevant data.
740  * Reimplemented from YUIException.
741  **/
742  virtual std::ostream & dumpOn( std::ostream & str ) const
743  {
744  std::string containerWidgetClass =
745  container() ? container()->widgetClass() :
746  "widget";
747 
748  std::string childWidgetClass =
749  child() ? child()->widgetClass() :
750  "<Null>";
751 
752  return str << childWidgetClass
753  << " is not a child of "
754  << containerWidgetClass
755  << std::endl;
756  }
757 
758 private:
759 
760  YWidget * _container;
761  YWidget * _child;
762 };
763 
764 
765 
766 /**
767  * Exception class for "optional widget not supported".
768  *
769  * Note that applications are supposed to check with
770  * YUI::optionalWidgetFactory()->hasXYWidget() before trying to create such a
771  * widget. This exception is thrown if that check wasn't done, the application
772  * tried to create that kind of widget anyway, but the UI doesn't support that
773  * widget.
774  **/
776 {
777 public:
778 
779  YUIUnsupportedWidgetException( const std::string & widgetType )
780  : YUIException( std::string( "Unsupported optional widget type: " ) + widgetType )
781  {}
782 
783  virtual ~YUIUnsupportedWidgetException() throw()
784  {}
785 };
786 
787 
788 /**
789  * Exception class for "value other than YD_HORIZ or YD_VERT used for
790  * dimension".
791  **/
793 {
794 public:
796  : YUIException( "Invalid dimension (neither YD_HORIZ nor YD_VERT)" )
797  {}
798 
799  virtual ~YUIInvalidDimensionException() throw()
800  {}
801 };
802 
803 
804 /**
805  * Exception class for "index out of range"
806  **/
808 {
809 public:
810  /**
811  * Constructor.
812  *
813  * 'invalidIndex' is the offending index value. It should be between
814  *'validMin' and 'validMax':
815  *
816  * validMin <= index <= validMax
817  **/
818  YUIIndexOutOfRangeException( int invalidIndex,
819  int validMin,
820  int validMax,
821  const std::string & msg = "" )
822  : YUIException( msg )
823  , _invalidIndex( invalidIndex )
824  , _validMin( validMin )
825  , _validMax( validMax )
826  {}
827 
828  virtual ~YUIIndexOutOfRangeException() throw()
829  {}
830 
831  /**
832  * Return the offending index value.
833  **/
834  int invalidIndex() const { return _invalidIndex; }
835 
836  /**
837  * Return the valid minimum index.
838  **/
839  int validMin() const { return _validMin; }
840 
841  /**
842  * Return the valid maximum index.
843  **/
844  int validMax() const { return _validMax; }
845 
846 protected:
847 
848  /**
849  * Write proper error message with all relevant data.
850  * Reimplemented from YUIException.
851  **/
852  virtual std::ostream & dumpOn( std::ostream & str ) const
853  {
854  std::string prefix = msg();
855 
856  if ( prefix.empty() )
857  prefix = "Index out of range";
858 
859  return str << prefix << ": " << _invalidIndex
860  << " valid: " << _validMin << " .. " << _validMax
861  << std::endl;
862  }
863 
864 private:
865 
866  int _invalidIndex;
867  int _validMin;
868  int _validMax;
869 };
870 
871 
872 /**
873  * Exception class for plugin load failure
874  **/
876 {
877 public:
878  YUIPluginException( const std::string & pluginName )
879  : YUIException( std::string( "Couldn't load plug-in " ) + pluginName )
880  {}
881 
882  virtual ~YUIPluginException() throw()
883  {}
884 };
885 
886 
887 /**
888  * Exception class for UI plugin load failure
889  **/
891 {
892 public:
894  : YUIException( "No $DISPLAY and stdout is not a tty" )
895  {}
896 
897  virtual ~YUICantLoadAnyUIException() throw()
898  {}
899 };
900 
901 
902 /**
903  * Exception class for "wrong button roles in YButtonBox"
904  **/
906 {
907 public:
908 
909  YUIButtonRoleMismatchException( const std::string & msg )
910  : YUIException( msg )
911  {}
912 
913  virtual ~YUIButtonRoleMismatchException() throw()
914  {}
915 };
916 
917 
918 //
919 // Helper templates
920 //
921 
922 
923 /**
924  * Helper for YUI_THROW()
925  **/
926 template<class _Exception>
927 void _YUI_THROW( const _Exception & exception_r, const YCodeLocation & where_r )
928 {
929  exception_r.relocate( where_r );
930  YUIException::log( exception_r, where_r, "THROW: " );
931  throw( exception_r );
932 }
933 
934 
935 /**
936  * Helper for YUI_CAUGHT()
937  **/
938 template<class _Exception>
939 void _YUI_CAUGHT( const _Exception & exception_r, const YCodeLocation & where_r )
940 {
941  YUIException::log( exception_r, where_r, "CAUGHT: " );
942 }
943 
944 
945 /**
946  * Helper for YUI_RETHROW()
947  **/
948 template<class _Exception>
949 void _YUI_RETHROW( const _Exception & exception_r, const YCodeLocation & where_r )
950 {
951  YUIException::log( exception_r, where_r, "RETHROW: " );
952  exception_r.relocate( where_r );
953  throw;
954 }
955 
956 
957 #endif // YUIException_h
YProperty property() const
Returns the property that caused this exception.
Definition: YUIException.h:523
YPropertyType type() const
Return the property type the application tried to set.
Definition: YUIException.h:595
Exception class for "index out of range".
Definition: YUIException.h:807
void relocate(const YCodeLocation &newLocation) const
Exchange location on rethrow.
Definition: YUIException.h:326
Exception class for attempt to set a read-only property.
Definition: YUIException.h:613
void setMsg(const std::string &msg)
Set a new message string.
Definition: YUIException.h:340
Exception class for "too many children": Attempt to add a child to a widget class that can&#39;t handle c...
Definition: YUIException.h:663
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YWidget.h:72
YWidget * child() const
Returns the child widget.
Definition: YUIException.h:734
YWidget * container() const
Returns the container widget that can&#39;t handle that many children.
Definition: YUIException.h:678
int line() const
Returns the source line number where the exception occured.
Definition: YUIException.h:264
int validMax() const
Return the valid maximum index.
Definition: YUIException.h:844
void setWidget(YWidget *w)
Set the corresponding widget.
Definition: YUIException.h:533
YCodeLocation(const std::string &file_r, const std::string &func_r, int line_r)
Constructor.
Definition: YUIException.h:236
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: YUIException.h:852
Exception class for "wrong button roles in YButtonBox".
Definition: YUIException.h:905
friend std::ostream & operator<<(std::ostream &str, const YCodeLocation &obj)
Stream output.
Definition: YUIException.cc:56
Exception class for "value other than YD_HORIZ or YD_VERT used for dimension".
Definition: YUIException.h:792
YWidget * container() const
Returns the container widget whose child should be removed etc.
Definition: YUIException.h:729
std::string func() const
Returns the name of the function where the exception occured.
Definition: YUIException.h:259
virtual const char * what() const
Return message string.
Definition: YUIException.h:370
std::string file() const
Returns the source file name where the exception occured.
Definition: YUIException.h:254
YUIIndexOutOfRangeException(int invalidIndex, int validMin, int validMax, const std::string &msg="")
Constructor.
Definition: YUIException.h:818
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: YUIException.h:742
Exception class for invalid widgets.
Definition: YUIException.h:440
Exception class for plugin load failure.
Definition: YUIException.h:875
int validMin() const
Return the valid minimum index.
Definition: YUIException.h:839
Exception class for "out of memory".
Definition: YUIException.h:423
Exception class for "optional widget not supported".
Definition: YUIException.h:775
Exception class for "No widget found with that ID".
Definition: YUIException.h:455
Exception class for "unknown property name": The application tried to set (or query) a property that ...
Definition: YUIException.h:553
YCodeLocation()
Default constructor.
Definition: YUIException.h:247
Class for widget properties.
Definition: YProperty.h:51
Helper class for UI exceptions: Store FILE, FUNCTION and LINE.
Definition: YUIException.h:229
const std::string & msg() const
Return the message string provided to the constructor.
Definition: YUIException.h:334
Exception class for "property type mismatch": The application tried to set a property with a wrong ty...
Definition: YUIException.h:578
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:407
Exception class for "invalid child".
Definition: YUIException.h:712
virtual std::ostream & dumpOn(std::ostream &str) const
Write proper error message with all relevant data.
Definition: YUIException.h:686
Exception class for UI plugin load failure.
Definition: YUIException.h:890
std::string asString() const
Returns the location in normalized string format.
Definition: YUIException.cc:41
Abstract base class for widget property exceptions.
Definition: YUIException.h:506
int invalidIndex() const
Return the offending index value.
Definition: YUIException.h:834
Abstract base class of all UI widgets.
Definition: YWidget.h:54
const YCodeLocation & where() const
Return YCodeLocation.
Definition: YUIException.h:320
Base class for UI Exceptions.
Definition: YUIException.h:297
YWidget * widget() const
Returns the corresponding widget or 0 if there was none.
Definition: YUIException.h:528