OpenMS  2.7.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 <new>
42 #include <string>
43 #include <stdexcept>
44 
45 namespace OpenMS
46 {
47 
62  namespace Exception
63  {
64 
90  class OPENMS_DLLAPI BaseException :
91  public std::runtime_error
92  {
93 public:
94 
98 
100  BaseException() noexcept;
101 
103  BaseException(const char* file, int line, const char* function) noexcept;
104 
106  BaseException(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
107 
110 
112  ~BaseException() noexcept override;
114 
118 
120  const char* getName() const noexcept;
121 
123  int getLine() const noexcept;
124 
126  const char* getFile() const noexcept;
127 
129  const char* getFunction() const noexcept;
130 
132  const char* getMessage() const noexcept;
133 
135 
136 protected:
137 
139  const char* file_;
140 
142  int line_;
143 
145  const char* function_;
146 
148  std::string name_;
149  };
150 
158  class OPENMS_DLLAPI Precondition :
159  public BaseException
160  {
161 public:
162  Precondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
163  };
164 
172  class OPENMS_DLLAPI Postcondition :
173  public BaseException
174  {
175 public:
176  Postcondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
177  };
178 
187  class OPENMS_DLLAPI MissingInformation :
188  public BaseException
189  {
190 public:
191  MissingInformation(const char* file, int line, const char* function, const std::string& error_message) noexcept;
192  };
193 
194 
208  class OPENMS_DLLAPI IndexUnderflow :
209  public BaseException
210  {
211 public:
212  IndexUnderflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
213  };
214 
227  class OPENMS_DLLAPI SizeUnderflow :
228  public BaseException
229  {
230 public:
231  SizeUnderflow(const char* file, int line, const char* function, Size size = 0) noexcept;
232  };
233 
246  class OPENMS_DLLAPI IndexOverflow :
247  public BaseException
248  {
249 public:
250  IndexOverflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
251  };
252 
263  class OPENMS_DLLAPI FailedAPICall :
264  public BaseException
265  {
266 public:
267  FailedAPICall(const char* file, int line, const char* function, const std::string& message) noexcept;
268  };
269 
277  class OPENMS_DLLAPI InvalidRange :
278  public BaseException
279  {
280 public:
281  InvalidRange(const char* file, int line, const char* function) 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 #ifdef _MSC_VER // disable some seqan warnings that distract from ours
460 # pragma warning( push ) // save warning state
461 # pragma warning( disable : 4275 )
462 #endif
463  class OPENMS_DLLAPI OutOfMemory :
464  public BaseException, public std::bad_alloc
465  {
466 public:
467  OutOfMemory(const char* file, int line, const char* function, Size size = 0) noexcept;
468  };
469 #ifdef _MSC_VER
470 # pragma warning( pop ) // restore old warning state
471 #endif
477  class OPENMS_DLLAPI BufferOverflow :
478  public BaseException
479  {
480 public:
481  BufferOverflow(const char* file, int line, const char* function) noexcept;
482  };
483 
489  class OPENMS_DLLAPI DivisionByZero :
490  public BaseException
491  {
492 public:
493  DivisionByZero(const char* file, int line, const char* function) noexcept;
494  };
495 
501  class OPENMS_DLLAPI OutOfGrid :
502  public BaseException
503  {
504 public:
505  OutOfGrid(const char* file, int line, const char* function) noexcept;
506  };
507 
515  class OPENMS_DLLAPI FileNotFound :
516  public BaseException
517  {
518 public:
519  FileNotFound(const char* file, int line, const char* function, const std::string& filename) noexcept;
520  };
521 
529  class OPENMS_DLLAPI FileNotReadable :
530  public BaseException
531  {
532 public:
533  FileNotReadable(const char* file, int line, const char* function, const std::string& filename) noexcept;
534  };
535 
543  class OPENMS_DLLAPI FileNotWritable :
544  public BaseException
545  {
546 public:
547  FileNotWritable(const char* file, int line, const char* function, const std::string& filename) noexcept;
548  };
549 
558  class OPENMS_DLLAPI FileNameTooLong :
559  public BaseException
560  {
561  public:
562  FileNameTooLong(const char* file, int line, const char* function, const std::string& filename, int max_length) noexcept;
563  };
564 
572  class OPENMS_DLLAPI IOException :
573  public BaseException
574  {
575 public:
576  IOException(const char* file, int line, const char* function, const std::string& filename) noexcept;
577  };
578 
586  class OPENMS_DLLAPI SqlOperationFailed :
587  public BaseException
588  {
589 public:
590  SqlOperationFailed(const char* file, int line, const char* function, const std::string& description) noexcept;
591  };
592 
600  class OPENMS_DLLAPI FileEmpty :
601  public BaseException
602  {
603 public:
604  FileEmpty(const char* file, int line, const char* function, const std::string& filename) noexcept;
605  };
606 
614  class OPENMS_DLLAPI IllegalPosition :
615  public BaseException
616  {
617 public:
618  IllegalPosition(const char* file, int line, const char* function, float x, float y, float z) noexcept;
619  };
620 
628  class OPENMS_DLLAPI ParseError :
629  public BaseException
630  {
631 public:
632  ParseError(const char* file, int line, const char* function, const std::string& expression, const std::string& message) noexcept;
633  };
634 
642  class OPENMS_DLLAPI UnableToCreateFile :
643  public BaseException
644  {
645 public:
646  UnableToCreateFile(const char* file, int line, const char* function, const std::string& filename, const std::string& message = "") noexcept;
647  };
648 
654  class OPENMS_DLLAPI IllegalArgument :
655  public BaseException
656  {
657 public:
658  IllegalArgument(const char* file, int line, const char* function, const std::string& error_message) noexcept;
659  };
660 
668  class OPENMS_DLLAPI ElementNotFound :
669  public BaseException
670  {
671 public:
672  ElementNotFound(const char* file, int line, const char* function, const std::string& element) noexcept;
673  };
674 
682  class OPENMS_DLLAPI UnableToFit :
683  public BaseException
684  {
685 public:
686  UnableToFit(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
687  };
688 
697  class OPENMS_DLLAPI UnableToCalibrate :
698  public BaseException
699  {
700 public:
701  UnableToCalibrate(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
702  };
703 
711  class OPENMS_DLLAPI DepletedIDPool :
712  public BaseException
713  {
714 public:
715  DepletedIDPool(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
716  };
717 
718  } // namespace Exception
719 
741  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Exception::BaseException& e);
742 
743 } // namespace OPENMS
744 
Exception base class.
Definition: Exception.h:92
BaseException() noexcept
Default constructor.
Buffer overflow exception.
Definition: Exception.h:479
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:713
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:491
DivisionByZero(const char *file, int line, const char *function) noexcept
Element could not be found exception.
Definition: Exception.h:670
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:265
FailedAPICall(const char *file, int line, const char *function, const std::string &message) noexcept
File is empty.
Definition: Exception.h:602
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:560
FileNameTooLong(const char *file, int line, const char *function, const std::string &filename, int max_length) noexcept
File not found exception.
Definition: Exception.h:517
FileNotFound(const char *file, int line, const char *function, const std::string &filename) noexcept
File not readable exception.
Definition: Exception.h:531
FileNotReadable(const char *file, int line, const char *function, const std::string &filename) noexcept
File not writable exception.
Definition: Exception.h:545
FileNotWritable(const char *file, int line, const char *function, const std::string &filename) noexcept
General IOException.
Definition: Exception.h:574
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:656
IllegalArgument(const char *file, int line, const char *function, const std::string &error_message) noexcept
Invalid 3-dimensional position exception.
Definition: Exception.h:616
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:248
IndexOverflow(const char *file, int line, const char *function, SignedSize index=0, Size size=0) noexcept
Int underflow exception.
Definition: Exception.h:210
IndexUnderflow(const char *file, int line, const char *function, SignedSize index=0, Size size=0) 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:279
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:189
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:503
OutOfGrid(const char *file, int line, const char *function) noexcept
Out of memory exception.
Definition: Exception.h:465
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:630
ParseError(const char *file, int line, const char *function, const std::string &expression, const std::string &message) noexcept
Postcondition failed exception.
Definition: Exception.h:174
Postcondition(const char *file, int line, const char *function, const std::string &condition) noexcept
Precondition failed exception.
Definition: Exception.h:160
Precondition(const char *file, int line, const char *function, const std::string &condition) noexcept
UInt underflow exception.
Definition: Exception.h:229
SizeUnderflow(const char *file, int line, const char *function, Size size=0) noexcept
SqlOperation failed exception.
Definition: Exception.h:588
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:699
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:644
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:684
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)