OpenMS  3.0.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-2022.
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 
108  BaseException(const BaseException& exception) noexcept;
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 
OpenMS::Exception::Postcondition
Postcondition failed exception.
Definition: Exception.h:171
OpenMS::Exception::InvalidIterator
Invalid iterator exception.
Definition: Exception.h:399
OpenMS::Exception::FileNameTooLong
Filename is too long to be writable/readable by the filesystem.
Definition: Exception.h:552
OpenMS::Exception::SizeUnderflow
UInt underflow exception.
Definition: Exception.h:226
OpenMS::Exception::IllegalArgument
A method or algorithm argument contains illegal values.
Definition: Exception.h:648
Types.h
OpenMS::Exception::BaseException::line_
int line_
The line number the exception was thrown in.
Definition: Exception.h:141
OpenMS::Exception::InvalidSize
Invalid UInt exception.
Definition: Exception.h:295
OpenMS::Exception::InvalidValue
Invalid value exception.
Definition: Exception.h:327
OpenMS::Exception::InternalToolError
A tool or algorithm which was called internally raised an exception.
Definition: Exception.h:660
OpenMS::Exception::IllegalTreeOperation
Illegal tree operation exception.
Definition: Exception.h:442
OpenMS::Exception::OutOfMemory
Out of memory exception.
Definition: Exception.h:459
OpenMS::Exception::Precondition
Precondition failed exception.
Definition: Exception.h:157
OpenMS::Exception::FileNotFound
File not found exception.
Definition: Exception.h:509
OpenMS::Exception::ConversionError
Invalid conversion exception.
Definition: Exception.h:354
OpenMS::Exception::InvalidRange
Invalid range exception.
Definition: Exception.h:276
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::Internal::ClassTest::exception
int exception
(Used by various macros. Indicates a rough category of the exception being caught....
OpenMS::Exception::IllegalPosition
Invalid 3-dimensional position exception.
Definition: Exception.h:608
OpenMS::Exception::OutOfGrid
Out of grid exception.
Definition: Exception.h:495
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:339
OpenMS::Exception::DepletedIDPool
Exception used if no more unique document ID's can be drawn from ID pool.
Definition: Exception.h:717
OpenMS::Exception::OutOfRange
Out of range exception.
Definition: Exception.h:311
OpenMS::Exception::DivisionByZero
Division by zero error exception.
Definition: Exception.h:483
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Exception::NullPointer
Null pointer argument is invalid exception.
Definition: Exception.h:385
OpenMS::Exception::FailedAPICall
A call to an external library (other than OpenMS) went wrong.
Definition: Exception.h:262
OpenMS::Exception::BufferOverflow
Buffer overflow exception.
Definition: Exception.h:471
OpenMS::Exception::UnableToCreateFile
Unable to create file exception.
Definition: Exception.h:636
OpenMS::Exception::BaseException::function_
const char * function_
The source file the exception was thrown in.
Definition: Exception.h:144
OpenMS::Exception::BaseException
Exception base class.
Definition: Exception.h:89
OpenMS::Exception::IOException
General IOException.
Definition: Exception.h:566
OpenMS::Exception::NotImplemented
Not implemented exception.
Definition: Exception.h:428
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::Exception::BaseException::name_
std::string name_
The name of the exception.
Definition: Exception.h:147
OpenMS::Exception::IndexOverflow
Int overflow exception.
Definition: Exception.h:245
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::Exception::SqlOperationFailed
SqlOperation failed exception.
Definition: Exception.h:580
OpenMS::Exception::ParseError
Parse Error exception.
Definition: Exception.h:622
OpenMS::Exception::IncompatibleIterators
Incompatible iterator exception.
Definition: Exception.h:414
OpenMS::Exception::FileNotWritable
File not writable exception.
Definition: Exception.h:537
OpenMS::Exception::BaseException::file_
const char * file_
The source file the exception was thrown in.
Definition: Exception.h:138
OpenMS::Exception::MissingInformation
Not all required information provided.
Definition: Exception.h:186
OpenMS::Exception::ElementNotFound
Element could not be found exception.
Definition: Exception.h:674
OpenMS::Exception::FileEmpty
File is empty.
Definition: Exception.h:594
OpenMS::Exception::UnableToFit
Exception used if an error occurred while fitting a model to a given dataset.
Definition: Exception.h:688
OpenMS::Exception::FileNotReadable
File not readable exception.
Definition: Exception.h:523
OpenMS::Exception::IllegalSelfOperation
Illegal self operation exception.
Definition: Exception.h:370
OpenMS::Exception::UnableToCalibrate
Exception used if an error occurred while calibrating a dataset.
Definition: Exception.h:703
OpenMS::Exception::IndexUnderflow
Int underflow exception.
Definition: Exception.h:207