OpenMS
Exception.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/CONCEPT/Types.h>
12 #include <OpenMS/OpenMSConfig.h>
13 #include <iosfwd>
14 #include <stdexcept>
15 #include <string>
16 
17 namespace OpenMS
18 {
19 
34  namespace Exception
35  {
36 
62  class OPENMS_DLLAPI BaseException : public std::runtime_error
63  {
64  public:
68 
70  BaseException() noexcept;
71 
73  BaseException(const char* file, int line, const char* function) noexcept;
74 
76  BaseException(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
77 
80 
82  ~BaseException() noexcept override;
84 
88 
90  const char* getName() const noexcept;
91 
93  int getLine() const noexcept;
94 
96  const char* getFile() const noexcept;
97 
99  const char* getFunction() const noexcept;
100 
102  const char* getMessage() const noexcept;
103 
105 
106  protected:
108  const char* file_;
109 
111  int line_;
112 
114  const char* function_;
115 
117  std::string name_;
118  };
119 
127  class OPENMS_DLLAPI Precondition : public BaseException
128  {
129  public:
130  Precondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
131  };
132 
140  class OPENMS_DLLAPI Postcondition : public BaseException
141  {
142  public:
143  Postcondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
144  };
145 
154  class OPENMS_DLLAPI MissingInformation : public BaseException
155  {
156  public:
157  MissingInformation(const char* file, int line, const char* function, const std::string& error_message) noexcept;
158  };
159 
160 
174  class OPENMS_DLLAPI IndexUnderflow : public BaseException
175  {
176  public:
177  IndexUnderflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
178  };
179 
192  class OPENMS_DLLAPI SizeUnderflow : public BaseException
193  {
194  public:
195  SizeUnderflow(const char* file, int line, const char* function, Size size = 0) noexcept;
196  };
197 
210  class OPENMS_DLLAPI IndexOverflow : public BaseException
211  {
212  public:
213  IndexOverflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
214  };
215 
226  class OPENMS_DLLAPI FailedAPICall : public BaseException
227  {
228  public:
229  FailedAPICall(const char* file, int line, const char* function, const std::string& message) noexcept;
230  };
231 
239  class OPENMS_DLLAPI InvalidRange : public BaseException
240  {
241  public:
242  InvalidRange(const char* file, int line, const char* function) noexcept;
243  InvalidRange(const char* file, int line, const char* function, const std::string& message) noexcept;
244  };
245 
246 
257  class OPENMS_DLLAPI InvalidSize : public BaseException
258  {
259  public:
260  InvalidSize(const char* file, int line, const char* function, Size size = 0) noexcept;
261  };
262 
263 
272  class OPENMS_DLLAPI OutOfRange : public BaseException
273  {
274  public:
275  OutOfRange(const char* file, int line, const char* function) noexcept;
276  };
277 
287  class OPENMS_DLLAPI InvalidValue : public BaseException
288  {
289  public:
290  InvalidValue(const char* file, int line, const char* function, const std::string& message, const std::string& value) noexcept;
291  };
292 
298  class OPENMS_DLLAPI InvalidParameter : public BaseException
299  {
300  public:
301  InvalidParameter(const char* file, int line, const char* function, const std::string& message) noexcept;
302  };
303 
312  class OPENMS_DLLAPI ConversionError : public BaseException
313  {
314  public:
315  ConversionError(const char* file, int line, const char* function, const std::string& error) noexcept;
316  };
317 
327  class OPENMS_DLLAPI IllegalSelfOperation : public BaseException
328  {
329  public:
330  IllegalSelfOperation(const char* file, int line, const char* function) noexcept;
331  };
332 
341  class OPENMS_DLLAPI NullPointer : public BaseException
342  {
343  public:
344  NullPointer(const char* file, int line, const char* function) noexcept;
345  };
346 
354  class OPENMS_DLLAPI InvalidIterator : public BaseException
355  {
356  public:
357  InvalidIterator(const char* file, int line, const char* function) noexcept;
358  };
359 
368  class OPENMS_DLLAPI IncompatibleIterators : public BaseException
369  {
370  public:
371  IncompatibleIterators(const char* file, int line, const char* function) noexcept;
372  };
373 
381  class OPENMS_DLLAPI NotImplemented : public BaseException
382  {
383  public:
384  NotImplemented(const char* file, int line, const char* function) noexcept;
385  };
386 
394  class OPENMS_DLLAPI IllegalTreeOperation : public BaseException
395  {
396  public:
397  IllegalTreeOperation(const char* file, int line, const char* function) noexcept;
398  };
399 
410  class OPENMS_DLLAPI OutOfMemory : public BaseException, public std::bad_alloc
411  {
412  public:
413  OutOfMemory(const char* file, int line, const char* function, Size size = 0) noexcept;
414  };
415 
421  class OPENMS_DLLAPI BufferOverflow : public BaseException
422  {
423  public:
424  BufferOverflow(const char* file, int line, const char* function) noexcept;
425  };
426 
432  class OPENMS_DLLAPI DivisionByZero : public BaseException
433  {
434  public:
435  DivisionByZero(const char* file, int line, const char* function) noexcept;
436  };
437 
443  class OPENMS_DLLAPI OutOfGrid : public BaseException
444  {
445  public:
446  OutOfGrid(const char* file, int line, const char* function) noexcept;
447  };
448 
456  class OPENMS_DLLAPI FileNotFound : public BaseException
457  {
458  public:
459  FileNotFound(const char* file, int line, const char* function, const std::string& filename) noexcept;
460  };
461 
469  class OPENMS_DLLAPI FileNotReadable : public BaseException
470  {
471  public:
472  FileNotReadable(const char* file, int line, const char* function, const std::string& filename) noexcept;
473  };
474 
482  class OPENMS_DLLAPI FileNotWritable : public BaseException
483  {
484  public:
485  FileNotWritable(const char* file, int line, const char* function, const std::string& filename) noexcept;
486  };
487 
496  class OPENMS_DLLAPI FileNameTooLong : public BaseException
497  {
498  public:
499  FileNameTooLong(const char* file, int line, const char* function, const std::string& filename, int max_length) noexcept;
500  };
501 
509  class OPENMS_DLLAPI IOException : public BaseException
510  {
511  public:
512  IOException(const char* file, int line, const char* function, const std::string& filename) noexcept;
513  };
514 
522  class OPENMS_DLLAPI SqlOperationFailed : public BaseException
523  {
524  public:
525  SqlOperationFailed(const char* file, int line, const char* function, const std::string& description) noexcept;
526  };
527 
535  class OPENMS_DLLAPI FileEmpty : public BaseException
536  {
537  public:
538  FileEmpty(const char* file, int line, const char* function, const std::string& filename) noexcept;
539  };
540 
548  class OPENMS_DLLAPI IllegalPosition : public BaseException
549  {
550  public:
551  IllegalPosition(const char* file, int line, const char* function, float x, float y, float z) noexcept;
552  };
553 
561  class OPENMS_DLLAPI ParseError : public BaseException
562  {
563  public:
564  ParseError(const char* file, int line, const char* function, const std::string& expression, const std::string& message) noexcept;
565  };
566 
574  class OPENMS_DLLAPI UnableToCreateFile : public BaseException
575  {
576  public:
577  UnableToCreateFile(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
578  };
579 
587  class OPENMS_DLLAPI InvalidFileType : public BaseException
588  {
589  public:
590  InvalidFileType(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
591  };
592 
598  class OPENMS_DLLAPI IllegalArgument : public BaseException
599  {
600  public:
601  IllegalArgument(const char* file, int line, const char* function, const std::string& error_message) noexcept;
602  };
603 
609  class OPENMS_DLLAPI InternalToolError : public BaseException
610  {
611  public:
612  InternalToolError(const char* file, int line, const char* function, const std::string& error_message) noexcept;
613  };
614 
622  class OPENMS_DLLAPI ElementNotFound : public BaseException
623  {
624  public:
625  ElementNotFound(const char* file, int line, const char* function, const std::string& element) noexcept;
626  };
627 
635  class OPENMS_DLLAPI UnableToFit : public BaseException
636  {
637  public:
638  UnableToFit(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
639  };
640 
649  class OPENMS_DLLAPI UnableToCalibrate : public BaseException
650  {
651  public:
652  UnableToCalibrate(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
653  };
654 
662  class OPENMS_DLLAPI DepletedIDPool : public BaseException
663  {
664  public:
665  DepletedIDPool(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
666  };
667 
668  } // namespace Exception
669 
691  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Exception::BaseException& e);
692 
693 } // namespace OpenMS
Exception base class.
Definition: Exception.h:63
BaseException() noexcept
Default constructor.
Buffer overflow exception.
Definition: Exception.h:422
BufferOverflow(const char *file, int line, const char *function) noexcept
Invalid conversion exception.
Definition: Exception.h:313
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:663
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:433
DivisionByZero(const char *file, int line, const char *function) noexcept
Element could not be found exception.
Definition: Exception.h:623
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:227
FailedAPICall(const char *file, int line, const char *function, const std::string &message) noexcept
File is empty.
Definition: Exception.h:536
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:497
FileNameTooLong(const char *file, int line, const char *function, const std::string &filename, int max_length) noexcept
File not found exception.
Definition: Exception.h:457
FileNotFound(const char *file, int line, const char *function, const std::string &filename) noexcept
File not readable exception.
Definition: Exception.h:470
FileNotReadable(const char *file, int line, const char *function, const std::string &filename) noexcept
File not writable exception.
Definition: Exception.h:483
FileNotWritable(const char *file, int line, const char *function, const std::string &filename) noexcept
General IOException.
Definition: Exception.h:510
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:599
IllegalArgument(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid 3-dimensional position exception.
Definition: Exception.h:549
IllegalPosition(const char *file, int line, const char *function, float x, float y, float z) noexcept
Illegal self operation exception.
Definition: Exception.h:328
IllegalSelfOperation(const char *file, int line, const char *function) noexcept
Illegal tree operation exception.
Definition: Exception.h:395
IllegalTreeOperation(const char *file, int line, const char *function) noexcept
Incompatible iterator exception.
Definition: Exception.h:369
IncompatibleIterators(const char *file, int line, const char *function) noexcept
Int overflow exception.
Definition: Exception.h:211
IndexOverflow(const char *file, int line, const char *function, SignedSize index=0, Size size=0) noexcept
Int underflow exception.
Definition: Exception.h:175
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:610
InternalToolError(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid file type exception.
Definition: Exception.h:588
InvalidFileType(const char *file, int line, const char *function, const std::string &filename, const std::string &message="") noexcept
Invalid iterator exception.
Definition: Exception.h:355
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:299
InvalidParameter(const char *file, int line, const char *function, const std::string &message) noexcept
Invalid range exception.
Definition: Exception.h:240
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:258
InvalidSize(const char *file, int line, const char *function, Size size=0) noexcept
Invalid value exception.
Definition: Exception.h:288
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:155
MissingInformation(const char *file, int line, const char *function, const std::string &error_message) noexcept
Not implemented exception.
Definition: Exception.h:382
NotImplemented(const char *file, int line, const char *function) noexcept
Null pointer argument is invalid exception.
Definition: Exception.h:342
NullPointer(const char *file, int line, const char *function) noexcept
Out of grid exception.
Definition: Exception.h:444
OutOfGrid(const char *file, int line, const char *function) noexcept
Out of memory exception.
Definition: Exception.h:411
OutOfMemory(const char *file, int line, const char *function, Size size=0) noexcept
Out of range exception.
Definition: Exception.h:273
OutOfRange(const char *file, int line, const char *function) noexcept
Parse Error exception.
Definition: Exception.h:562
ParseError(const char *file, int line, const char *function, const std::string &expression, const std::string &message) noexcept
Postcondition failed exception.
Definition: Exception.h:141
Postcondition(const char *file, int line, const char *function, const std::string &condition) noexcept
Precondition failed exception.
Definition: Exception.h:128
Precondition(const char *file, int line, const char *function, const std::string &condition) noexcept
UInt underflow exception.
Definition: Exception.h:193
SizeUnderflow(const char *file, int line, const char *function, Size size=0) noexcept
SqlOperation failed exception.
Definition: Exception.h:523
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:650
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:575
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:636
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:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)