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 
216 
227  class OPENMS_DLLAPI NotSorted : public BaseException
228  {
229  public:
230  NotSorted(const char* file, int line, const char* function, const std::string& message) noexcept;
231  };
232 
243  class OPENMS_DLLAPI FailedAPICall : public BaseException
244  {
245  public:
246  FailedAPICall(const char* file, int line, const char* function, const std::string& message) noexcept;
247  };
248 
256  class OPENMS_DLLAPI InvalidRange : public BaseException
257  {
258  public:
259  InvalidRange(const char* file, int line, const char* function) noexcept;
260  InvalidRange(const char* file, int line, const char* function, const std::string& message) noexcept;
261  };
262 
263 
274  class OPENMS_DLLAPI InvalidSize : public BaseException
275  {
276  public:
277  InvalidSize(const char* file, int line, const char* function, Size size = 0) noexcept;
278  };
279 
280 
289  class OPENMS_DLLAPI OutOfRange : public BaseException
290  {
291  public:
292  OutOfRange(const char* file, int line, const char* function) noexcept;
293  };
294 
304  class OPENMS_DLLAPI InvalidValue : public BaseException
305  {
306  public:
307  InvalidValue(const char* file, int line, const char* function, const std::string& message, const std::string& value) noexcept;
308  };
309 
315  class OPENMS_DLLAPI InvalidParameter : public BaseException
316  {
317  public:
318  InvalidParameter(const char* file, int line, const char* function, const std::string& message) noexcept;
319  };
320 
329  class OPENMS_DLLAPI ConversionError : public BaseException
330  {
331  public:
332  ConversionError(const char* file, int line, const char* function, const std::string& error) noexcept;
333  };
334 
344  class OPENMS_DLLAPI IllegalSelfOperation : public BaseException
345  {
346  public:
347  IllegalSelfOperation(const char* file, int line, const char* function) noexcept;
348  };
349 
358  class OPENMS_DLLAPI NullPointer : public BaseException
359  {
360  public:
361  NullPointer(const char* file, int line, const char* function) noexcept;
362  };
363 
371  class OPENMS_DLLAPI InvalidIterator : public BaseException
372  {
373  public:
374  InvalidIterator(const char* file, int line, const char* function) noexcept;
375  };
376 
385  class OPENMS_DLLAPI IncompatibleIterators : public BaseException
386  {
387  public:
388  IncompatibleIterators(const char* file, int line, const char* function) noexcept;
389  };
390 
398  class OPENMS_DLLAPI NotImplemented : public BaseException
399  {
400  public:
401  NotImplemented(const char* file, int line, const char* function) noexcept;
402  };
403 
411  class OPENMS_DLLAPI IllegalTreeOperation : public BaseException
412  {
413  public:
414  IllegalTreeOperation(const char* file, int line, const char* function) noexcept;
415  };
416 
427  class OPENMS_DLLAPI OutOfMemory : public BaseException, public std::bad_alloc
428  {
429  public:
430  OutOfMemory(const char* file, int line, const char* function, Size size = 0) noexcept;
431  };
432 
438  class OPENMS_DLLAPI BufferOverflow : public BaseException
439  {
440  public:
441  BufferOverflow(const char* file, int line, const char* function) noexcept;
442  };
443 
449  class OPENMS_DLLAPI DivisionByZero : public BaseException
450  {
451  public:
452  DivisionByZero(const char* file, int line, const char* function) noexcept;
453  };
454 
460  class OPENMS_DLLAPI OutOfGrid : public BaseException
461  {
462  public:
463  OutOfGrid(const char* file, int line, const char* function) noexcept;
464  };
465 
473  class OPENMS_DLLAPI FileNotFound : public BaseException
474  {
475  public:
476  FileNotFound(const char* file, int line, const char* function, const std::string& filename) noexcept;
477  };
478 
486  class OPENMS_DLLAPI FileNotReadable : public BaseException
487  {
488  public:
489  FileNotReadable(const char* file, int line, const char* function, const std::string& filename) noexcept;
490  };
491 
499  class OPENMS_DLLAPI FileNotWritable : public BaseException
500  {
501  public:
502  FileNotWritable(const char* file, int line, const char* function, const std::string& filename) noexcept;
503  };
504 
513  class OPENMS_DLLAPI FileNameTooLong : public BaseException
514  {
515  public:
516  FileNameTooLong(const char* file, int line, const char* function, const std::string& filename, int max_length) noexcept;
517  };
518 
526  class OPENMS_DLLAPI IOException : public BaseException
527  {
528  public:
529  IOException(const char* file, int line, const char* function, const std::string& filename) noexcept;
530  };
531 
539  class OPENMS_DLLAPI SqlOperationFailed : public BaseException
540  {
541  public:
542  SqlOperationFailed(const char* file, int line, const char* function, const std::string& description) noexcept;
543  };
544 
552  class OPENMS_DLLAPI FileEmpty : public BaseException
553  {
554  public:
555  FileEmpty(const char* file, int line, const char* function, const std::string& filename) noexcept;
556  };
557 
565  class OPENMS_DLLAPI IllegalPosition : public BaseException
566  {
567  public:
568  IllegalPosition(const char* file, int line, const char* function, float x, float y, float z) noexcept;
569  };
570 
578  class OPENMS_DLLAPI ParseError : public BaseException
579  {
580  public:
581  ParseError(const char* file, int line, const char* function, const std::string& expression, const std::string& message) noexcept;
582  };
583 
591  class OPENMS_DLLAPI UnableToCreateFile : public BaseException
592  {
593  public:
594  UnableToCreateFile(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
595  };
596 
604  class OPENMS_DLLAPI InvalidFileType : public BaseException
605  {
606  public:
607  InvalidFileType(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
608  };
609 
615  class OPENMS_DLLAPI IllegalArgument : public BaseException
616  {
617  public:
618  IllegalArgument(const char* file, int line, const char* function, const std::string& error_message) noexcept;
619  };
620 
626  class OPENMS_DLLAPI InternalToolError : public BaseException
627  {
628  public:
629  InternalToolError(const char* file, int line, const char* function, const std::string& error_message) noexcept;
630  };
631 
639  class OPENMS_DLLAPI ElementNotFound : public BaseException
640  {
641  public:
642  ElementNotFound(const char* file, int line, const char* function, const std::string& element) noexcept;
643  };
644 
652  class OPENMS_DLLAPI UnableToFit : public BaseException
653  {
654  public:
655  UnableToFit(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
656  };
657 
666  class OPENMS_DLLAPI UnableToCalibrate : public BaseException
667  {
668  public:
669  UnableToCalibrate(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
670  };
671 
679  class OPENMS_DLLAPI DepletedIDPool : public BaseException
680  {
681  public:
682  DepletedIDPool(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
683  };
684 
685  } // namespace Exception
686 
708  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Exception::BaseException& e);
709 
710 } // namespace OpenMS
Exception base class.
Definition: Exception.h:63
BaseException() noexcept
Default constructor.
Buffer overflow exception.
Definition: Exception.h:439
BufferOverflow(const char *file, int line, const char *function) noexcept
Invalid conversion exception.
Definition: Exception.h:330
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:680
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:450
DivisionByZero(const char *file, int line, const char *function) noexcept
Element could not be found exception.
Definition: Exception.h:640
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:244
FailedAPICall(const char *file, int line, const char *function, const std::string &message) noexcept
File is empty.
Definition: Exception.h:553
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:514
FileNameTooLong(const char *file, int line, const char *function, const std::string &filename, int max_length) noexcept
File not found exception.
Definition: Exception.h:474
FileNotFound(const char *file, int line, const char *function, const std::string &filename) noexcept
File not readable exception.
Definition: Exception.h:487
FileNotReadable(const char *file, int line, const char *function, const std::string &filename) noexcept
File not writable exception.
Definition: Exception.h:500
FileNotWritable(const char *file, int line, const char *function, const std::string &filename) noexcept
General IOException.
Definition: Exception.h:527
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:616
IllegalArgument(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid 3-dimensional position exception.
Definition: Exception.h:566
IllegalPosition(const char *file, int line, const char *function, float x, float y, float z) noexcept
Illegal self operation exception.
Definition: Exception.h:345
IllegalSelfOperation(const char *file, int line, const char *function) noexcept
Illegal tree operation exception.
Definition: Exception.h:412
IllegalTreeOperation(const char *file, int line, const char *function) noexcept
Incompatible iterator exception.
Definition: Exception.h:386
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:627
InternalToolError(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid file type exception.
Definition: Exception.h:605
InvalidFileType(const char *file, int line, const char *function, const std::string &filename, const std::string &message="") noexcept
Invalid iterator exception.
Definition: Exception.h:372
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:316
InvalidParameter(const char *file, int line, const char *function, const std::string &message) noexcept
Invalid range exception.
Definition: Exception.h:257
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:275
InvalidSize(const char *file, int line, const char *function, Size size=0) noexcept
Invalid value exception.
Definition: Exception.h:305
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:399
NotImplemented(const char *file, int line, const char *function) noexcept
Array not sorted exception.
Definition: Exception.h:228
NotSorted(const char *file, int line, const char *function, const std::string &message) noexcept
Null pointer argument is invalid exception.
Definition: Exception.h:359
NullPointer(const char *file, int line, const char *function) noexcept
Out of grid exception.
Definition: Exception.h:461
OutOfGrid(const char *file, int line, const char *function) noexcept
Out of memory exception.
Definition: Exception.h:428
OutOfMemory(const char *file, int line, const char *function, Size size=0) noexcept
Out of range exception.
Definition: Exception.h:290
OutOfRange(const char *file, int line, const char *function) noexcept
Parse Error exception.
Definition: Exception.h:579
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:540
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:667
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:592
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:653
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)