OpenMS
Exception.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, 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/OpenMSConfig.h>
12 #include <OpenMS/CONCEPT/Types.h>
13 
14 #include <iosfwd>
15 #include <string>
16 #include <stdexcept>
17 
18 namespace OpenMS
19 {
20 
35  namespace Exception
36  {
37 
63  class OPENMS_DLLAPI BaseException :
64  public std::runtime_error
65  {
66 public:
67 
71 
73  BaseException() noexcept;
74 
76  BaseException(const char* file, int line, const char* function) noexcept;
77 
79  BaseException(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
80 
83 
85  ~BaseException() noexcept override;
87 
91 
93  const char* getName() const noexcept;
94 
96  int getLine() const noexcept;
97 
99  const char* getFile() const noexcept;
100 
102  const char* getFunction() const noexcept;
103 
105  const char* getMessage() const noexcept;
106 
108 
109 protected:
110 
112  const char* file_;
113 
115  int line_;
116 
118  const char* function_;
119 
121  std::string name_;
122  };
123 
131  class OPENMS_DLLAPI Precondition :
132  public BaseException
133  {
134 public:
135  Precondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
136  };
137 
145  class OPENMS_DLLAPI Postcondition :
146  public BaseException
147  {
148 public:
149  Postcondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
150  };
151 
160  class OPENMS_DLLAPI MissingInformation :
161  public BaseException
162  {
163 public:
164  MissingInformation(const char* file, int line, const char* function, const std::string& error_message) noexcept;
165  };
166 
167 
181  class OPENMS_DLLAPI IndexUnderflow :
182  public BaseException
183  {
184 public:
185  IndexUnderflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
186  };
187 
200  class OPENMS_DLLAPI SizeUnderflow :
201  public BaseException
202  {
203 public:
204  SizeUnderflow(const char* file, int line, const char* function, Size size = 0) noexcept;
205  };
206 
219  class OPENMS_DLLAPI IndexOverflow :
220  public BaseException
221  {
222 public:
223  IndexOverflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
224  };
225 
236  class OPENMS_DLLAPI FailedAPICall :
237  public BaseException
238  {
239 public:
240  FailedAPICall(const char* file, int line, const char* function, const std::string& message) noexcept;
241  };
242 
250  class OPENMS_DLLAPI InvalidRange :
251  public BaseException
252  {
253 public:
254  InvalidRange(const char* file, int line, const char* function) noexcept;
255  InvalidRange(const char* file, int line, const char* function, const std::string& message) noexcept;
256  };
257 
258 
269  class OPENMS_DLLAPI InvalidSize :
270  public BaseException
271  {
272 public:
273  InvalidSize(const char* file, int line, const char* function, Size size = 0) noexcept;
274  };
275 
276 
285  class OPENMS_DLLAPI OutOfRange :
286  public BaseException
287  {
288 public:
289  OutOfRange(const char* file, int line, const char* function) noexcept;
290  };
291 
301  class OPENMS_DLLAPI InvalidValue :
302  public BaseException
303  {
304 public:
305  InvalidValue(const char* file, int line, const char* function, const std::string& message, const std::string& value) noexcept;
306  };
307 
313  class OPENMS_DLLAPI InvalidParameter :
314  public BaseException
315  {
316 public:
317  InvalidParameter(const char* file, int line, const char* function, const std::string& message) noexcept;
318  };
319 
328  class OPENMS_DLLAPI ConversionError :
329  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 :
345  public BaseException
346  {
347 public:
348  IllegalSelfOperation(const char* file, int line, const char* function) noexcept;
349  };
350 
359  class OPENMS_DLLAPI NullPointer :
360  public BaseException
361  {
362 public:
363  NullPointer(const char* file, int line, const char* function) noexcept;
364  };
365 
373  class OPENMS_DLLAPI InvalidIterator :
374  public BaseException
375  {
376 public:
377  InvalidIterator(const char* file, int line, const char* function) noexcept;
378  };
379 
388  class OPENMS_DLLAPI IncompatibleIterators :
389  public BaseException
390  {
391 public:
392  IncompatibleIterators(const char* file, int line, const char* function) noexcept;
393  };
394 
402  class OPENMS_DLLAPI NotImplemented :
403  public BaseException
404  {
405 public:
406  NotImplemented(const char* file, int line, const char* function) noexcept;
407  };
408 
416  class OPENMS_DLLAPI IllegalTreeOperation :
417  public BaseException
418  {
419 public:
420  IllegalTreeOperation(const char* file, int line, const char* function) noexcept;
421  };
422 
433  class OPENMS_DLLAPI OutOfMemory :
434  public BaseException, public std::bad_alloc
435  {
436 public:
437  OutOfMemory(const char* file, int line, const char* function, Size size = 0) noexcept;
438  };
439 
445  class OPENMS_DLLAPI BufferOverflow :
446  public BaseException
447  {
448 public:
449  BufferOverflow(const char* file, int line, const char* function) noexcept;
450  };
451 
457  class OPENMS_DLLAPI DivisionByZero :
458  public BaseException
459  {
460 public:
461  DivisionByZero(const char* file, int line, const char* function) noexcept;
462  };
463 
469  class OPENMS_DLLAPI OutOfGrid :
470  public BaseException
471  {
472 public:
473  OutOfGrid(const char* file, int line, const char* function) noexcept;
474  };
475 
483  class OPENMS_DLLAPI FileNotFound :
484  public BaseException
485  {
486 public:
487  FileNotFound(const char* file, int line, const char* function, const std::string& filename) noexcept;
488  };
489 
497  class OPENMS_DLLAPI FileNotReadable :
498  public BaseException
499  {
500 public:
501  FileNotReadable(const char* file, int line, const char* function, const std::string& filename) noexcept;
502  };
503 
511  class OPENMS_DLLAPI FileNotWritable :
512  public BaseException
513  {
514 public:
515  FileNotWritable(const char* file, int line, const char* function, const std::string& filename) noexcept;
516  };
517 
526  class OPENMS_DLLAPI FileNameTooLong :
527  public BaseException
528  {
529  public:
530  FileNameTooLong(const char* file, int line, const char* function, const std::string& filename, int max_length) noexcept;
531  };
532 
540  class OPENMS_DLLAPI IOException :
541  public BaseException
542  {
543 public:
544  IOException(const char* file, int line, const char* function, const std::string& filename) noexcept;
545  };
546 
554  class OPENMS_DLLAPI SqlOperationFailed :
555  public BaseException
556  {
557 public:
558  SqlOperationFailed(const char* file, int line, const char* function, const std::string& description) noexcept;
559  };
560 
568  class OPENMS_DLLAPI FileEmpty :
569  public BaseException
570  {
571 public:
572  FileEmpty(const char* file, int line, const char* function, const std::string& filename) noexcept;
573  };
574 
582  class OPENMS_DLLAPI IllegalPosition :
583  public BaseException
584  {
585 public:
586  IllegalPosition(const char* file, int line, const char* function, float x, float y, float z) noexcept;
587  };
588 
596  class OPENMS_DLLAPI ParseError :
597  public BaseException
598  {
599 public:
600  ParseError(const char* file, int line, const char* function, const std::string& expression, const std::string& message) noexcept;
601  };
602 
610  class OPENMS_DLLAPI UnableToCreateFile :
611  public BaseException
612  {
613 public:
614  UnableToCreateFile(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
615  };
616 
622  class OPENMS_DLLAPI IllegalArgument :
623  public BaseException
624  {
625 public:
626  IllegalArgument(const char* file, int line, const char* function, const std::string& error_message) noexcept;
627  };
628 
634  class OPENMS_DLLAPI InternalToolError :
635  public BaseException
636  {
637  public:
638  InternalToolError(const char* file, int line, const char* function, const std::string& error_message) noexcept;
639  };
640 
648  class OPENMS_DLLAPI ElementNotFound :
649  public BaseException
650  {
651 public:
652  ElementNotFound(const char* file, int line, const char* function, const std::string& element) noexcept;
653  };
654 
662  class OPENMS_DLLAPI UnableToFit :
663  public BaseException
664  {
665 public:
666  UnableToFit(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
667  };
668 
677  class OPENMS_DLLAPI UnableToCalibrate :
678  public BaseException
679  {
680 public:
681  UnableToCalibrate(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
682  };
683 
691  class OPENMS_DLLAPI DepletedIDPool :
692  public BaseException
693  {
694 public:
695  DepletedIDPool(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
696  };
697 
698  } // namespace Exception
699 
721  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Exception::BaseException& e);
722 
723 } // namespace OPENMS
724 
Exception base class.
Definition: Exception.h:65
BaseException() noexcept
Default constructor.
Buffer overflow exception.
Definition: Exception.h:447
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:693
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:459
DivisionByZero(const char *file, int line, const char *function) noexcept
Element could not be found exception.
Definition: Exception.h:650
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:238
FailedAPICall(const char *file, int line, const char *function, const std::string &message) noexcept
File is empty.
Definition: Exception.h:570
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:528
FileNameTooLong(const char *file, int line, const char *function, const std::string &filename, int max_length) noexcept
File not found exception.
Definition: Exception.h:485
FileNotFound(const char *file, int line, const char *function, const std::string &filename) noexcept
File not readable exception.
Definition: Exception.h:499
FileNotReadable(const char *file, int line, const char *function, const std::string &filename) noexcept
File not writable exception.
Definition: Exception.h:513
FileNotWritable(const char *file, int line, const char *function, const std::string &filename) noexcept
General IOException.
Definition: Exception.h:542
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:624
IllegalArgument(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid 3-dimensional position exception.
Definition: Exception.h:584
IllegalPosition(const char *file, int line, const char *function, float x, float y, float z) noexcept
Illegal self operation exception.
Definition: Exception.h:346
IllegalSelfOperation(const char *file, int line, const char *function) noexcept
Illegal tree operation exception.
Definition: Exception.h:418
IllegalTreeOperation(const char *file, int line, const char *function) noexcept
Incompatible iterator exception.
Definition: Exception.h:390
IncompatibleIterators(const char *file, int line, const char *function) noexcept
Int overflow exception.
Definition: Exception.h:221
IndexOverflow(const char *file, int line, const char *function, SignedSize index=0, Size size=0) noexcept
Int underflow exception.
Definition: Exception.h:183
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:636
InternalToolError(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid iterator exception.
Definition: Exception.h:375
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:315
InvalidParameter(const char *file, int line, const char *function, const std::string &message) noexcept
Invalid range exception.
Definition: Exception.h:252
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:271
InvalidSize(const char *file, int line, const char *function, Size size=0) noexcept
Invalid value exception.
Definition: Exception.h:303
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:162
MissingInformation(const char *file, int line, const char *function, const std::string &error_message) noexcept
Not implemented exception.
Definition: Exception.h:404
NotImplemented(const char *file, int line, const char *function) noexcept
Null pointer argument is invalid exception.
Definition: Exception.h:361
NullPointer(const char *file, int line, const char *function) noexcept
Out of grid exception.
Definition: Exception.h:471
OutOfGrid(const char *file, int line, const char *function) noexcept
Out of memory exception.
Definition: Exception.h:435
OutOfMemory(const char *file, int line, const char *function, Size size=0) noexcept
Out of range exception.
Definition: Exception.h:287
OutOfRange(const char *file, int line, const char *function) noexcept
Parse Error exception.
Definition: Exception.h:598
ParseError(const char *file, int line, const char *function, const std::string &expression, const std::string &message) noexcept
Postcondition failed exception.
Definition: Exception.h:147
Postcondition(const char *file, int line, const char *function, const std::string &condition) noexcept
Precondition failed exception.
Definition: Exception.h:133
Precondition(const char *file, int line, const char *function, const std::string &condition) noexcept
UInt underflow exception.
Definition: Exception.h:202
SizeUnderflow(const char *file, int line, const char *function, Size size=0) noexcept
SqlOperation failed exception.
Definition: Exception.h:556
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:679
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:612
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:664
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:108
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)