OpenMS  2.8.0
Exception.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/OpenMSConfig.h>
38 #include <OpenMS/CONCEPT/Types.h>
39 
40 #include <iosfwd>
41 #include <string>
42 #include <stdexcept>
43 
44 namespace OpenMS
45 {
46 
61  namespace Exception
62  {
63 
89  class OPENMS_DLLAPI BaseException :
90  public std::runtime_error
91  {
92 public:
93 
97 
99  BaseException() noexcept;
100 
102  BaseException(const char* file, int line, const char* function) noexcept;
103 
105  BaseException(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
106 
109 
111  ~BaseException() noexcept override;
113 
117 
119  const char* getName() const noexcept;
120 
122  int getLine() const noexcept;
123 
125  const char* getFile() const noexcept;
126 
128  const char* getFunction() const noexcept;
129 
131  const char* getMessage() const noexcept;
132 
134 
135 protected:
136 
138  const char* file_;
139 
141  int line_;
142 
144  const char* function_;
145 
147  std::string name_;
148  };
149 
157  class OPENMS_DLLAPI Precondition :
158  public BaseException
159  {
160 public:
161  Precondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
162  };
163 
171  class OPENMS_DLLAPI Postcondition :
172  public BaseException
173  {
174 public:
175  Postcondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
176  };
177 
186  class OPENMS_DLLAPI MissingInformation :
187  public BaseException
188  {
189 public:
190  MissingInformation(const char* file, int line, const char* function, const std::string& error_message) noexcept;
191  };
192 
193 
207  class OPENMS_DLLAPI IndexUnderflow :
208  public BaseException
209  {
210 public:
211  IndexUnderflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
212  };
213 
226  class OPENMS_DLLAPI SizeUnderflow :
227  public BaseException
228  {
229 public:
230  SizeUnderflow(const char* file, int line, const char* function, Size size = 0) noexcept;
231  };
232 
245  class OPENMS_DLLAPI IndexOverflow :
246  public BaseException
247  {
248 public:
249  IndexOverflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
250  };
251 
262  class OPENMS_DLLAPI FailedAPICall :
263  public BaseException
264  {
265 public:
266  FailedAPICall(const char* file, int line, const char* function, const std::string& message) noexcept;
267  };
268 
276  class OPENMS_DLLAPI InvalidRange :
277  public BaseException
278  {
279 public:
280  InvalidRange(const char* file, int line, const char* function) noexcept;
281  InvalidRange(const char* file, int line, const char* function, const std::string& message) noexcept;
282  };
283 
284 
295  class OPENMS_DLLAPI InvalidSize :
296  public BaseException
297  {
298 public:
299  InvalidSize(const char* file, int line, const char* function, Size size = 0) noexcept;
300  };
301 
302 
311  class OPENMS_DLLAPI OutOfRange :
312  public BaseException
313  {
314 public:
315  OutOfRange(const char* file, int line, const char* function) noexcept;
316  };
317 
327  class OPENMS_DLLAPI InvalidValue :
328  public BaseException
329  {
330 public:
331  InvalidValue(const char* file, int line, const char* function, const std::string& message, const std::string& value) noexcept;
332  };
333 
339  class OPENMS_DLLAPI InvalidParameter :
340  public BaseException
341  {
342 public:
343  InvalidParameter(const char* file, int line, const char* function, const std::string& message) noexcept;
344  };
345 
354  class OPENMS_DLLAPI ConversionError :
355  public BaseException
356  {
357 public:
358  ConversionError(const char* file, int line, const char* function, const std::string& error) noexcept;
359  };
360 
370  class OPENMS_DLLAPI IllegalSelfOperation :
371  public BaseException
372  {
373 public:
374  IllegalSelfOperation(const char* file, int line, const char* function) noexcept;
375  };
376 
385  class OPENMS_DLLAPI NullPointer :
386  public BaseException
387  {
388 public:
389  NullPointer(const char* file, int line, const char* function) noexcept;
390  };
391 
399  class OPENMS_DLLAPI InvalidIterator :
400  public BaseException
401  {
402 public:
403  InvalidIterator(const char* file, int line, const char* function) noexcept;
404  };
405 
414  class OPENMS_DLLAPI IncompatibleIterators :
415  public BaseException
416  {
417 public:
418  IncompatibleIterators(const char* file, int line, const char* function) noexcept;
419  };
420 
428  class OPENMS_DLLAPI NotImplemented :
429  public BaseException
430  {
431 public:
432  NotImplemented(const char* file, int line, const char* function) noexcept;
433  };
434 
442  class OPENMS_DLLAPI IllegalTreeOperation :
443  public BaseException
444  {
445 public:
446  IllegalTreeOperation(const char* file, int line, const char* function) noexcept;
447  };
448 
459  class OPENMS_DLLAPI OutOfMemory :
460  public BaseException, public std::bad_alloc
461  {
462 public:
463  OutOfMemory(const char* file, int line, const char* function, Size size = 0) noexcept;
464  };
465 
471  class OPENMS_DLLAPI BufferOverflow :
472  public BaseException
473  {
474 public:
475  BufferOverflow(const char* file, int line, const char* function) noexcept;
476  };
477 
483  class OPENMS_DLLAPI DivisionByZero :
484  public BaseException
485  {
486 public:
487  DivisionByZero(const char* file, int line, const char* function) noexcept;
488  };
489 
495  class OPENMS_DLLAPI OutOfGrid :
496  public BaseException
497  {
498 public:
499  OutOfGrid(const char* file, int line, const char* function) noexcept;
500  };
501 
509  class OPENMS_DLLAPI FileNotFound :
510  public BaseException
511  {
512 public:
513  FileNotFound(const char* file, int line, const char* function, const std::string& filename) noexcept;
514  };
515 
523  class OPENMS_DLLAPI FileNotReadable :
524  public BaseException
525  {
526 public:
527  FileNotReadable(const char* file, int line, const char* function, const std::string& filename) noexcept;
528  };
529 
537  class OPENMS_DLLAPI FileNotWritable :
538  public BaseException
539  {
540 public:
541  FileNotWritable(const char* file, int line, const char* function, const std::string& filename) noexcept;
542  };
543 
552  class OPENMS_DLLAPI FileNameTooLong :
553  public BaseException
554  {
555  public:
556  FileNameTooLong(const char* file, int line, const char* function, const std::string& filename, int max_length) noexcept;
557  };
558 
566  class OPENMS_DLLAPI IOException :
567  public BaseException
568  {
569 public:
570  IOException(const char* file, int line, const char* function, const std::string& filename) noexcept;
571  };
572 
580  class OPENMS_DLLAPI SqlOperationFailed :
581  public BaseException
582  {
583 public:
584  SqlOperationFailed(const char* file, int line, const char* function, const std::string& description) noexcept;
585  };
586 
594  class OPENMS_DLLAPI FileEmpty :
595  public BaseException
596  {
597 public:
598  FileEmpty(const char* file, int line, const char* function, const std::string& filename) noexcept;
599  };
600 
608  class OPENMS_DLLAPI IllegalPosition :
609  public BaseException
610  {
611 public:
612  IllegalPosition(const char* file, int line, const char* function, float x, float y, float z) noexcept;
613  };
614 
622  class OPENMS_DLLAPI ParseError :
623  public BaseException
624  {
625 public:
626  ParseError(const char* file, int line, const char* function, const std::string& expression, const std::string& message) noexcept;
627  };
628 
636  class OPENMS_DLLAPI UnableToCreateFile :
637  public BaseException
638  {
639 public:
640  UnableToCreateFile(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
641  };
642 
648  class OPENMS_DLLAPI IllegalArgument :
649  public BaseException
650  {
651 public:
652  IllegalArgument(const char* file, int line, const char* function, const std::string& error_message) noexcept;
653  };
654 
660  class OPENMS_DLLAPI InternalToolError :
661  public BaseException
662  {
663  public:
664  InternalToolError(const char* file, int line, const char* function, const std::string& error_message) noexcept;
665  };
666 
674  class OPENMS_DLLAPI ElementNotFound :
675  public BaseException
676  {
677 public:
678  ElementNotFound(const char* file, int line, const char* function, const std::string& element) noexcept;
679  };
680 
688  class OPENMS_DLLAPI UnableToFit :
689  public BaseException
690  {
691 public:
692  UnableToFit(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
693  };
694 
703  class OPENMS_DLLAPI UnableToCalibrate :
704  public BaseException
705  {
706 public:
707  UnableToCalibrate(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
708  };
709 
717  class OPENMS_DLLAPI DepletedIDPool :
718  public BaseException
719  {
720 public:
721  DepletedIDPool(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
722  };
723 
724  } // namespace Exception
725 
747  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Exception::BaseException& e);
748 
749 } // namespace OPENMS
750 
Exception base class.
Definition: Exception.h:91
BaseException() noexcept
Default constructor.
Buffer overflow exception.
Definition: Exception.h:473
BufferOverflow(const char *file, int line, const char *function) noexcept
Invalid conversion exception.
Definition: Exception.h:356
ConversionError(const char *file, int line, const char *function, const std::string &error) noexcept
Exception used if no more unique document ID's can be drawn from ID pool.
Definition: Exception.h:719
DepletedIDPool(const char *file, int line, const char *function, const std::string &name, const std::string &message) noexcept
Division by zero error exception.
Definition: Exception.h:485
DivisionByZero(const char *file, int line, const char *function) noexcept
Element could not be found exception.
Definition: Exception.h:676
ElementNotFound(const char *file, int line, const char *function, const std::string &element) noexcept
A call to an external library (other than OpenMS) went wrong.
Definition: Exception.h:264
FailedAPICall(const char *file, int line, const char *function, const std::string &message) noexcept
File is empty.
Definition: Exception.h:596
FileEmpty(const char *file, int line, const char *function, const std::string &filename) noexcept
Filename is too long to be writable/readable by the filesystem.
Definition: Exception.h:554
FileNameTooLong(const char *file, int line, const char *function, const std::string &filename, int max_length) noexcept
File not found exception.
Definition: Exception.h:511
FileNotFound(const char *file, int line, const char *function, const std::string &filename) noexcept
File not readable exception.
Definition: Exception.h:525
FileNotReadable(const char *file, int line, const char *function, const std::string &filename) noexcept
File not writable exception.
Definition: Exception.h:539
FileNotWritable(const char *file, int line, const char *function, const std::string &filename) noexcept
General IOException.
Definition: Exception.h:568
IOException(const char *file, int line, const char *function, const std::string &filename) noexcept
A method or algorithm argument contains illegal values.
Definition: Exception.h:650
IllegalArgument(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid 3-dimensional position exception.
Definition: Exception.h:610
IllegalPosition(const char *file, int line, const char *function, float x, float y, float z) noexcept
Illegal self operation exception.
Definition: Exception.h:372
IllegalSelfOperation(const char *file, int line, const char *function) noexcept
Illegal tree operation exception.
Definition: Exception.h:444
IllegalTreeOperation(const char *file, int line, const char *function) noexcept
Incompatible iterator exception.
Definition: Exception.h:416
IncompatibleIterators(const char *file, int line, const char *function) noexcept
Int overflow exception.
Definition: Exception.h:247
IndexOverflow(const char *file, int line, const char *function, SignedSize index=0, Size size=0) noexcept
Int underflow exception.
Definition: Exception.h:209
IndexUnderflow(const char *file, int line, const char *function, SignedSize index=0, Size size=0) noexcept
A tool or algorithm which was called internally raised an exception.
Definition: Exception.h:662
InternalToolError(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid iterator exception.
Definition: Exception.h:401
InvalidIterator(const char *file, int line, const char *function) noexcept
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:341
InvalidParameter(const char *file, int line, const char *function, const std::string &message) noexcept
Invalid range exception.
Definition: Exception.h:278
InvalidRange(const char *file, int line, const char *function, const std::string &message) noexcept
InvalidRange(const char *file, int line, const char *function) noexcept
Invalid UInt exception.
Definition: Exception.h:297
InvalidSize(const char *file, int line, const char *function, Size size=0) noexcept
Invalid value exception.
Definition: Exception.h:329
InvalidValue(const char *file, int line, const char *function, const std::string &message, const std::string &value) noexcept
Not all required information provided.
Definition: Exception.h:188
MissingInformation(const char *file, int line, const char *function, const std::string &error_message) noexcept
Not implemented exception.
Definition: Exception.h:430
NotImplemented(const char *file, int line, const char *function) noexcept
Null pointer argument is invalid exception.
Definition: Exception.h:387
NullPointer(const char *file, int line, const char *function) noexcept
Out of grid exception.
Definition: Exception.h:497
OutOfGrid(const char *file, int line, const char *function) noexcept
Out of memory exception.
Definition: Exception.h:461
OutOfMemory(const char *file, int line, const char *function, Size size=0) noexcept
Out of range exception.
Definition: Exception.h:313
OutOfRange(const char *file, int line, const char *function) noexcept
Parse Error exception.
Definition: Exception.h:624
ParseError(const char *file, int line, const char *function, const std::string &expression, const std::string &message) noexcept
Postcondition failed exception.
Definition: Exception.h:173
Postcondition(const char *file, int line, const char *function, const std::string &condition) noexcept
Precondition failed exception.
Definition: Exception.h:159
Precondition(const char *file, int line, const char *function, const std::string &condition) noexcept
UInt underflow exception.
Definition: Exception.h:228
SizeUnderflow(const char *file, int line, const char *function, Size size=0) noexcept
SqlOperation failed exception.
Definition: Exception.h:582
SqlOperationFailed(const char *file, int line, const char *function, const std::string &description) noexcept
Exception used if an error occurred while calibrating a dataset.
Definition: Exception.h:705
UnableToCalibrate(const char *file, int line, const char *function, const std::string &name, const std::string &message) noexcept
Unable to create file exception.
Definition: Exception.h:638
UnableToCreateFile(const char *file, int line, const char *function, const std::string &filename, const std::string &message="") noexcept
Exception used if an error occurred while fitting a model to a given dataset.
Definition: Exception.h:690
UnableToFit(const char *file, int line, const char *function, const std::string &name, const std::string &message) noexcept
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)