Exception.h 29.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
// $Id: Exception.h,v 1.58 2012-07-08 20:02:33 avalassi Exp $
#ifndef COOLKERNEL_EXCEPTION_H
#define COOLKERNEL_EXCEPTION_H 1

// First of all, enable or disable the COOL290 API extensions (bug #92204)
#include "CoolKernel/VersionInfo.h"

// Include files
#include <sstream>
#include <exception>
#include "CoolKernel/ChannelId.h"
#include "CoolKernel/ValidityKey.h"

namespace cool {

  //--------------------------------------------------------------------------

  /** @class Exception Exception.h
   *
   *  Top-level base exception class of the COOL package.
   *  Derived from std::exception.
   *
   *  @author Andrea Valassi, Sven A. Schmidt and Marco Clemencic
   *  @date   2004-10-27
   *///

  class Exception : public std::exception {

  public:

    /// Constructor
    explicit Exception( const std::string& message,
                        const std::string& domain )
      : m_message( message )
      , m_domain( domain ) {}

    /// Destructor
    virtual ~Exception() throw() {}

    /// Error reporting method
    virtual const char* what() const throw()
    {
      return m_message.c_str();
    }

    /// Return the error domain
    virtual const std::string& domain() const
    {
      return m_domain;
    }

  protected:

    /// Set the error message
    virtual void setMessage( const std::string& message )
    {
      m_message = message;
    }

  private:

    std::string m_message;
    std::string m_domain;

  };

  //--------------------------------------------------------------------------

  /** @class DatabaseNotOpen
   *
   *  Exception thrown when a database is not open.
   *///

  class DatabaseNotOpen : public Exception {

  public:

    /// Constructor
    explicit DatabaseNotOpen( const std::string& domain )
      : Exception( "The database is not open", domain ) {}

    /// Destructor
    virtual ~DatabaseNotOpen() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class DatabaseDoesNotExist
   *
   *  Exception thrown when a database does not exist.
   *///

  class DatabaseDoesNotExist : public Exception {

  public:

    /// Constructor
    explicit DatabaseDoesNotExist( const std::string& domain )
      : Exception( "The database does not exist", domain ) {}

    /// Destructor
    virtual ~DatabaseDoesNotExist() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class DatabaseOpenInReadOnlyMode
   *
   *  Exception thrown when attempting to update a database
   *  that is open in read-only mode.
   *///

  class DatabaseOpenInReadOnlyMode : public Exception {

  public:

    /// Constructor
    explicit DatabaseOpenInReadOnlyMode( const std::string& domain )
      : Exception
        ( "The database is open in read-only mode and cannot be updated",
          domain ) {}

    /// Destructor
    virtual ~DatabaseOpenInReadOnlyMode() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class NodeExists
   *
   *  Exception thrown during folder or folderset creation when
   *  a folder or folder set with that name already exists.
   *///

  class NodeExists : public Exception {

  public:

    /// Constructor
    explicit NodeExists( const std::string& fullPath,
                         const std::string& domain )
      : Exception( "Node " + fullPath + " already exists", domain ) {}

    /// Destructor
    virtual ~NodeExists() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class NodeNotFound
   *
   *  Exception thrown when a node with a given name, id and/or other
   *  properties cannot be found (e.g. a node with a given id does not exist,
   *  or a node with a given full name is a folder and not a folder set).
   *///

  class NodeNotFound : public Exception {

  public:

    /// Constructor
    explicit NodeNotFound( const std::string& message,
                           const std::string& domain )
      : Exception( message, domain ) {}

    /// Constructor
    explicit NodeNotFound( UInt32 nodeId,
                           const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "Node #" << nodeId << " not found";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~NodeNotFound() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class FolderNotFound
   *
   *  Exception thrown when a folder with a given name cannot be found
   *  (either because a node with that name does not exist or because
   *  the name indicates a folder set).
   *///

  class FolderNotFound : public NodeNotFound {

  public:

    /// Constructor
    explicit FolderNotFound( const std::string& fullPath,
                             const std::string& domain,
                             bool isFolderSet = false )
      : NodeNotFound( "Folder " + fullPath + " not found", domain )
      , m_isFolderSet( isFolderSet ) {}

    /// Destructor
    virtual ~FolderNotFound() throw() {}

    /// Does the full path indicate a folder set instead of a folder?
    bool isFolderSet() const { return m_isFolderSet; }

  private:

    /// Does the full path indicate a folder set instead of a folder?
    bool m_isFolderSet;

  };

  //--------------------------------------------------------------------------

  /** @class FolderSetNotFound
   *
   *  Exception thrown when a folder set with a given name cannot be found
   *  (either because a node with that name does not exist or because the
   *  name indicates a folder).
   *///

  class FolderSetNotFound : public NodeNotFound {

  public:

    /// Constructor
    explicit FolderSetNotFound( const std::string& fullPath,
                                const std::string& domain,
                                bool isFolder = false )
      : NodeNotFound( "Folder set " + fullPath + " not found", domain )
      , m_isFolder( isFolder ) {}

    /// Destructor
    virtual ~FolderSetNotFound() throw() {}

    /// Does the full path indicate a folder instead of a folder set?
    bool isFolder() const { return m_isFolder; }

  private:

    /// Does the full path indicate a folder instead of a folder set?
    bool m_isFolder;

  };

  //--------------------------------------------------------------------------

  /** @class NodeIsSingleVersion
   *
   *  Exception thrown when an HVS node does not support HVS tagging because
   *  it exists in a single version.
   *///

  class NodeIsSingleVersion : public Exception {

  public:

    /// Constructor
    explicit NodeIsSingleVersion( const std::string& message,
                                  const std::string& domain )
      : Exception( message, domain ) {}

    /// Destructor
    virtual ~NodeIsSingleVersion() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class FolderIsSingleVersion
   *
   *  Exception thrown when tagging operations are attempted within
   *  a folder that does not support versioning (single-version folder).
   *///

  class FolderIsSingleVersion : public NodeIsSingleVersion {

  public:

    /// Constructor
    explicit FolderIsSingleVersion( const std::string& fullPath,
                                    const std::string& domain )
      : NodeIsSingleVersion( "", domain )
    {
      std::ostringstream msg;
      msg << "Folder " << fullPath
          << " does not support IOV versioning or HVS tagging"
          << " (single version folder)";
      setMessage( msg.str() );
    }

    /// Constructor
    explicit FolderIsSingleVersion( const std::string& fullPath,
                                    const std::string& message,
                                    const std::string& domain )
      : NodeIsSingleVersion( "", domain )
    {
      std::ostringstream msg;
      msg << "Folder " << fullPath
          << " does not support IOV versioning or HVS tagging"
          << " (single version folder) - " << message;
      setMessage( msg.str() );
    }

    /// Constructor
    explicit FolderIsSingleVersion( UInt32 nodeId,
                                    const std::string& domain )
      : NodeIsSingleVersion( "", domain )
    {
      std::ostringstream msg;
      msg << "Folder #" << nodeId
          << " does not support IOV versioning or HVS tagging"
          << " (single version folder)";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~FolderIsSingleVersion() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class NodeRelationNotFound
   *
   *  Exception thrown when the expected ancestor-descendant relation
   *  between two given nodes cannot be found (either they are not related
   *  in any way, if the flag is false; or they are not parent and child,
   *  if the flag is true, but they still may be related more distantly).
   *///

  class NodeRelationNotFound : public Exception {

  public:

    /// Constructor
    explicit NodeRelationNotFound( UInt32 ancestorNodeId,
                                   UInt32 descendantNodeId,
                                   const std::string& domain,
                                   bool parentOnly = false )
      : Exception( "", domain )
      , m_parentOnly( parentOnly )
    {
      std::ostringstream msg;
#ifndef COOL290EX
      if ( parentOnly )
        msg << "Node #" << descendantNodeId
            << " is not a descendant of node #" << ancestorNodeId;
      else
        msg << "Node #" << descendantNodeId
            << " is not a child of node #" << ancestorNodeId;
#else
      if ( parentOnly )
        msg << "Node #" << descendantNodeId
            << " is not a child of node #" << ancestorNodeId;
      else
        msg << "Node #" << descendantNodeId
            << " is not a descendant of node #" << ancestorNodeId;
#endif
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~NodeRelationNotFound() throw() {}

    /// Was a parent-child relation the only tested relation?
    bool parentOnly() const { return m_parentOnly; }

  private:

    /// Was a parent-child relation the only tested relation?
    bool m_parentOnly;

  };

  //--------------------------------------------------------------------------

  /** @class ObjectNotFound
   *
   *  Exception thrown when an object does not exist.
   *///

  class ObjectNotFound : public Exception {

  public:

    /// Constructor
    explicit ObjectNotFound( const std::string& objectIdentity,
                             const std::string& objectContainer,
                             const std::string& domain )
      : Exception ( "Object at '" + objectIdentity
                    + "' not found in " + objectContainer,
                    domain ) {}

    /// Constructor
    explicit ObjectNotFound( const std::string& message,
                             const std::string& domain )
      : Exception ( "Object not found - " + message, domain ) {}

    /// Destructor
    virtual ~ObjectNotFound() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class TagExists
   *
   *  Exception thrown during tag creation when a tag already exists.
   *  Tag names, except for "HEAD", are case sensitive.
   *///

  class TagExists : public Exception {

  public:

    /// Constructor
    explicit TagExists( const std::string& tagName,
                        const std::string& domain )
      : Exception( "Tag '" + tagName + "' already exists", domain ) {}

    /// Destructor
    virtual ~TagExists() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class TagNotFound
   *
   *  Exception thrown when a tag does not exist.
   *  Tag names, except for "HEAD", are case sensitive.
   *///

  class TagNotFound : public Exception {

  public:

    /// Constructor
    explicit TagNotFound( const std::string& message,
                          const std::string& domain )
      : Exception( message, domain ) {}

    /// Constructor
    explicit TagNotFound( const std::string& tagName,
                          const std::string& nodeName,
                          const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "Tag '" << tagName << "' not found in node '" << nodeName << "'";
      setMessage( msg.str() );
    }

    /// Constructor
    explicit TagNotFound( const std::string& tagName,
                          UInt32 nodeId,
                          const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "Tag '" << tagName << "' not found in node #" << nodeId;
      setMessage( msg.str() );
    }

    /// Constructor
    explicit TagNotFound( UInt32 tagId,
                          UInt32 nodeId,
                          const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "Tag #" << tagId << " not found in node #" << nodeId;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~TagNotFound() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class ReservedHeadTag
   *
   *  Exception thrown when trying to create or delete the HEAD tag
   *  ("", "HEAD" or a case-insensitive variant such as "head" or "Head").
   *  Also thrown when trying to retrieve the name of the node where
   *  the HEAD tag is defined (it is defined in all folders).
   *///

  class ReservedHeadTag : public Exception {

  public:

    /// Constructor
    explicit ReservedHeadTag( const std::string& tagName,
                              const std::string& domain )
      : Exception( "Tag '" + tagName +
                   "' is a reserved HEAD tag: it is defined for all folders"
                   + " and cannot be created or deleted", domain ) {}

    /// Destructor
    virtual ~ReservedHeadTag() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class TagIsLocked
   *
   *  Exception thrown when attempting to modify a locked tag.
   *
   *///

  class TagIsLocked : public Exception {

  public:

    /// Constructor
    explicit TagIsLocked( const std::string& message,
                          const std::string& domain )
      : Exception( message, domain ) {}

    /// Destructor
    virtual ~TagIsLocked() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class InvalidTagRelation
   *
   *  Exception thrown when attempting to create an invalid tag relation,
   *  e.g. between the root node and its not-existing parent node
   *  or between two tags with the same name in different nodes.
   *///

  class InvalidTagRelation : public Exception {

  public:

    /// Constructor
    explicit InvalidTagRelation( const std::string& parentTagName,
                                 const std::string& childTagName,
                                 UInt32 childNodeId,
                                 const std::string& details,
                                 const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "A tag relation cannot be created"
          << " between tag '" << childTagName << "' in node #" << childNodeId
          << " and parent tag '" << parentTagName << "' in the parent node: "
          << details;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~InvalidTagRelation() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class TagRelationExists
   *
   *  Exception thrown when a child tag related to the given parent tag
   *  already exists in the given child of a given parent node.
   *///

  class TagRelationExists : public Exception {

  public:

    /// Constructor
    explicit TagRelationExists( UInt32 parentNodeId,
                                UInt32 parentTagId,
                                UInt32 childNodeId,
                                const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "A child tag already exists in node #" << childNodeId
          << " related to tag #" << parentTagId
          << " in parent node #" << parentNodeId;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~TagRelationExists() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class TagRelationNotFound
   *
   *  Exception thrown when no child tag related to the given parent tag
   *  can be found in the given child of a given parent node.
   *///

  class TagRelationNotFound : public Exception {

  public:

    /// Constructor
    explicit TagRelationNotFound( UInt32 parentNodeId,
                                  UInt32 parentTagId,
                                  UInt32 childNodeId,
                                  const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "No child tag can be found in node #" << childNodeId
          << " related to tag #" << parentTagId
          << " in parent node #" << parentNodeId;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~TagRelationNotFound() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class ValidityKeyException
   *
   *  Base exception class for validity key exceptions in COOL.
   *  Derived from COOL Exception.
   *
   *  @author Andrea Valassi and Sven A. Schmidt
   *  @date   2004-12-06
   *///

  class ValidityKeyException : public Exception {

  public:

    /// Constructor
    explicit ValidityKeyException( const std::string& message,
                                   const std::string& domain )
      : Exception( message, domain ) {}

    /// Destructor
    virtual ~ValidityKeyException() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class ValidityKeyOutOfBoundaries
   *
   *  Exception thrown when validity key is too low or too high.
   *///

  class ValidityKeyOutOfBoundaries : public ValidityKeyException {

  public:

    /// Constructor
    explicit ValidityKeyOutOfBoundaries( const ValidityKey& key,
                                         const std::string& domain )
      : ValidityKeyException( "", domain )
    {
      std::ostringstream msg;
      msg << "Validity key out of boundaries: key=" << key
          << ", min=" << ValidityKeyMin
          << ", max=" << ValidityKeyMax;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~ValidityKeyOutOfBoundaries() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class ValidityIntervalBackwards
   *
   *  Exception thrown when since > until in a validity interval.
   *///

  class ValidityIntervalBackwards : public ValidityKeyException {

  public:

    /// Constructor
    explicit ValidityIntervalBackwards( const ValidityKey& since,
                                        const ValidityKey& until,
                                        const std::string& domain )
      : ValidityKeyException( "", domain )
    {
      std::ostringstream msg;
      msg << "Validity interval has since>=until: since=" << since
          << ", until=" << until;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~ValidityIntervalBackwards() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class InvalidChannelName
   *
   *  Exception thrown when attempting to create a new channel or to
   *  select an existing channel in a folder using an invalid name.
   *
   *  Channel names must be between 1 and 255 characters long; they must
   *  start with a letter and must contain only letters, numbers or the '_'
   *  character (these constraints may be relaxed in a future COOL release).
   *  Channel names are unique: a ChannelNameExists exception is thrown when
   *  attempting to create a channel with a name that is already used.
   *  By default, channels are created with no name, i.e. with an empty string
   *  "" as their name: an InvalidChannelName is thrown when trying to select
   *  a channel using "" as its name, because several such channels exist.
   *
   *  @author Andrea Valassi
   *  @date   2006-12-16
   *///

  class InvalidChannelName : public Exception {

  public:

    /// Constructor
    explicit InvalidChannelName( size_t size,
                                 const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      if ( size == 0 )
        msg << "Empty string '' cannot be used to uniquely select channels";
      else
        msg << "Channel name is too long (size=" << size << ", maxSize=255)";
      setMessage( msg.str() );
    }

    /// Constructor
    explicit InvalidChannelName( const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "Invalid channel name: channel names must start with a letter"
          << " and contain only letters, numbers or the '_' character";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~InvalidChannelName() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class ChannelNotFound
   *
   *  Exception thrown when a channel with the given name or id does not exist.
   *
   *  @author Sven A. Schmidt and Andrea Valassi
   *  @date   2006-05-28
   *///

  class ChannelNotFound : public Exception {

  public:

    /// Constructor
    explicit ChannelNotFound( const std::string& channelName,
                              const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "No channel exists with name '" << channelName << "'";
      setMessage( msg.str() );
    }

    /// Constructor
    explicit ChannelNotFound( const ChannelId& channelId,
                              const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "No channel exists with id=" << channelId;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~ChannelNotFound() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class ChannelExists
   *
   *  Exception thrown when attempting to create a channel with a name
   *  or id that is already used by annother exsting channel.
   *
   *  @author Andrea Valassi
   *  @date   2006-12-16
   *///

  class ChannelExists : public Exception {

  public:

    /// Constructor
    explicit ChannelExists( const std::string& folderName,
                            const std::string& channelName,
                            const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "A channel with name '" << channelName << "' already exists"
          << " in folder '" << folderName << "'";
      setMessage( msg.str() );
    }

    /// Constructor
    explicit ChannelExists( const std::string& folderName,
                            const ChannelId& channelId,
                            const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "A channel with id=" << channelId << " already exists"
          << " in folder '" << folderName << "'";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~ChannelExists() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class InvalidChannelRange
   *
   *  Exception thrown when first > last channel in a ChannelSelection.
   *
   *  @author Sven A. Schmidt
   *  @date   2005-08-11
   *///

  class InvalidChannelRange : public Exception {

  public:

    /// Constructor
    explicit InvalidChannelRange( const ChannelId& firstChannel,
                                  const ChannelId& lastChannel,
                                  const std::string& domain )
      : Exception( "", domain )
    {
      std::ostringstream msg;
      msg << "ChannelSelection has first channel > last channel: first="
          << firstChannel << ", last=" << lastChannel;
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~InvalidChannelRange() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class InvalidFolderSpecification.
   *
   *  Exception thrown when attempting to create (a new folder using) an
   *  invalid folder specification (e.g. see bug #103343). Added in COOL290.
   *
   *  @author Andrea Valassi
   *  @date   2013-12-01
   *///

  class InvalidFolderSpecification : public Exception {

  public:

    /// Constructor
    explicit InvalidFolderSpecification( const std::string& message,
                                         const std::string& domain )
      : Exception( message, domain ) {}

    /// Destructor
    virtual ~InvalidFolderSpecification() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class InvalidPayloadSpecification.
   *
   *  Exception thrown when attempting to create a new folder using an
   *  invalid payload specification.
   *
   *  Payload specifications can have at most 900 fields, including up to 10
   *  BLOB fields and up to 200 String255 fields; field names must be between
   *  1 and 30 characters long (including only letters, digits or '_'), must
   *  start with a letter and cannot start with the "COOL_" prefix (in any
   *  combination of lowercase and uppercase letters).
   *
   *  @author Andrea Valassi
   *  @date   2007-01-08
   *///

  class InvalidPayloadSpecification :
#ifdef COOL290EX
    public InvalidFolderSpecification
#else
    public Exception
#endif
  {

  public:

    /// Constructor
    explicit InvalidPayloadSpecification( const std::string& message,
                                          const std::string& domain ) :
#ifdef COOL290EX
      InvalidFolderSpecification( message, domain )
#else
      Exception( message, domain )
#endif
    {}

    /// Destructor
    virtual ~InvalidPayloadSpecification() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class PayloadSpecificationTooManyFields.
   *
   *  Exception thrown when attempting to create a new folder using a
   *  payload specification with more than 900 fields.
   *
   *  @author Andrea Valassi
   *  @date   2007-01-08
   *///

  class PayloadSpecificationTooManyFields
    : public InvalidPayloadSpecification {

  public:

    /// Constructor
    explicit PayloadSpecificationTooManyFields( UInt32 nFields,
                                                const std::string& domain )
      : InvalidPayloadSpecification( "", domain )
    {
      std::ostringstream msg;
      msg << "Payload specification has too many fields: #fields="
          << nFields << ", max=900";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~PayloadSpecificationTooManyFields() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class PayloadSpecificationTooManyBlobFields.
   *
   *  Exception thrown when attempting to create a new folder using a
   *  payload specification with more than 10 BLOB fields.
   *
   *  @author Andrea Valassi
   *  @date   2007-01-08
   *///

  class PayloadSpecificationTooManyBlobFields
    : public InvalidPayloadSpecification {

  public:

    /// Constructor
    explicit PayloadSpecificationTooManyBlobFields( UInt32 nBlobFields,
                                                    const std::string& domain )
      : InvalidPayloadSpecification( "", domain )
    {
      std::ostringstream msg;
      msg << "Payload specification has too many BLOB fields: #blobFields="
          << nBlobFields << ", max=10";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~PayloadSpecificationTooManyBlobFields() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class PayloadSpecificationTooManyString255Fields.
   *
   *  Exception thrown when attempting to create a new folder using a
   *  payload specification with more than 200 String255 fields.
   *
   *  @author Andrea Valassi
   *  @date   2007-01-10
   *///

  class PayloadSpecificationTooManyString255Fields
    : public InvalidPayloadSpecification {

  public:

    /// Constructor
    explicit
    PayloadSpecificationTooManyString255Fields( UInt32 nString255Fields,
                                                const std::string& domain )
      : InvalidPayloadSpecification( "", domain )
    {
      std::ostringstream msg;
      msg << "Payload specification has too many String255 fields:"
          << " #string255Fields=" << nString255Fields << ", max=200";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~PayloadSpecificationTooManyString255Fields() throw() {}

  };

  //--------------------------------------------------------------------------

  /** @class PayloadSpecificationInvalidFieldName.
   *
   *  Exception thrown when attempting to create a new folder using a
   *  payload specification with one or more invalid field names.
   *
   *  Names of payload fields must have between 1 and 30 characters (including
   *  only letters, digits or '_'), must start with a letter and cannot start
   *  with the "COOL_" prefix (in any lowercase/uppercase combination).
   *
   *  @author Andrea Valassi
   *  @date   2007-01-08
   *///

  class PayloadSpecificationInvalidFieldName
    : public InvalidPayloadSpecification {

  public:

    /// Constructor
    explicit PayloadSpecificationInvalidFieldName( const std::string& name,
                                                   const std::string& domain )
      : InvalidPayloadSpecification( "", domain )
    {
      std::ostringstream msg;
      msg << "Payload field has invalid name '" << name << "'";
      setMessage( msg.str() );
    }

    /// Destructor
    virtual ~PayloadSpecificationInvalidFieldName() throw() {}

  };

  //--------------------------------------------------------------------------

}
#endif