OpenMS  2.6.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-2020.
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 
44 namespace OpenMS
45 {
46 
61  namespace Exception
62  {
63 
89  class OPENMS_DLLAPI BaseException :
90  public std::exception
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  const char* what() const noexcept override;
123 
125  int getLine() const noexcept;
126 
128  const char* getFile() const noexcept;
129 
131  const char* getFunction() const noexcept;
132 
134  const char* getMessage() const noexcept;
135 
137  void setMessage(const std::string& message) noexcept;
138 
140 
141 protected:
142 
144  const char* file_;
145 
147  int line_;
148 
150  const char* function_;
151 
153  std::string name_;
154 
156  std::string what_;
157  };
158 
166  class OPENMS_DLLAPI Precondition :
167  public BaseException
168  {
169 public:
170  Precondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
171  };
172 
180  class OPENMS_DLLAPI Postcondition :
181  public BaseException
182  {
183 public:
184  Postcondition(const char* file, int line, const char* function, const std::string& condition) noexcept;
185  };
186 
195  class OPENMS_DLLAPI MissingInformation :
196  public BaseException
197  {
198 public:
199  MissingInformation(const char* file, int line, const char* function, const std::string& error_message) noexcept;
200  };
201 
202 
216  class OPENMS_DLLAPI IndexUnderflow :
217  public BaseException
218  {
219 public:
220  IndexUnderflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
221  };
222 
235  class OPENMS_DLLAPI SizeUnderflow :
236  public BaseException
237  {
238 public:
239  SizeUnderflow(const char* file, int line, const char* function, Size size = 0) noexcept;
240  };
241 
254  class OPENMS_DLLAPI IndexOverflow :
255  public BaseException
256  {
257 public:
258  IndexOverflow(const char* file, int line, const char* function, SignedSize index = 0, Size size = 0) noexcept;
259  };
260 
271  class OPENMS_DLLAPI FailedAPICall :
272  public BaseException
273  {
274 public:
275  FailedAPICall(const char* file, int line, const char* function, const std::string& message) noexcept;
276  };
277 
285  class OPENMS_DLLAPI InvalidRange :
286  public BaseException
287  {
288 public:
289  InvalidRange(const char* file, int line, const char* function) noexcept;
290  };
291 
292 
303  class OPENMS_DLLAPI InvalidSize :
304  public BaseException
305  {
306 public:
307  InvalidSize(const char* file, int line, const char* function, Size size = 0) noexcept;
308  };
309 
310 
319  class OPENMS_DLLAPI OutOfRange :
320  public BaseException
321  {
322 public:
323  OutOfRange(const char* file, int line, const char* function) noexcept;
324  };
325 
335  class OPENMS_DLLAPI InvalidValue :
336  public BaseException
337  {
338 public:
339  InvalidValue(const char* file, int line, const char* function, const std::string& message, const std::string& value) noexcept;
340  };
341 
347  class OPENMS_DLLAPI InvalidParameter :
348  public BaseException
349  {
350 public:
351  InvalidParameter(const char* file, int line, const char* function, const std::string& message) noexcept;
352  };
353 
362  class OPENMS_DLLAPI ConversionError :
363  public BaseException
364  {
365 public:
366  ConversionError(const char* file, int line, const char* function, const std::string& error) noexcept;
367  };
368 
378  class OPENMS_DLLAPI IllegalSelfOperation :
379  public BaseException
380  {
381 public:
382  IllegalSelfOperation(const char* file, int line, const char* function) noexcept;
383  };
384 
393  class OPENMS_DLLAPI NullPointer :
394  public BaseException
395  {
396 public:
397  NullPointer(const char* file, int line, const char* function) noexcept;
398  };
399 
407  class OPENMS_DLLAPI InvalidIterator :
408  public BaseException
409  {
410 public:
411  InvalidIterator(const char* file, int line, const char* function) noexcept;
412  };
413 
422  class OPENMS_DLLAPI IncompatibleIterators :
423  public BaseException
424  {
425 public:
426  IncompatibleIterators(const char* file, int line, const char* function) noexcept;
427  };
428 
436  class OPENMS_DLLAPI NotImplemented :
437  public BaseException
438  {
439 public:
440  NotImplemented(const char* file, int line, const char* function) noexcept;
441  };
442 
450  class OPENMS_DLLAPI IllegalTreeOperation :
451  public BaseException
452  {
453 public:
454  IllegalTreeOperation(const char* file, int line, const char* function) noexcept;
455  };
456 
467 #ifdef _MSC_VER // disable some seqan warnings that distract from ours
468 # pragma warning( push ) // save warning state
469 # pragma warning( disable : 4275 )
470 #endif
471  class OPENMS_DLLAPI OutOfMemory :
472  public BaseException, public std::bad_alloc
473  {
474 public:
475  OutOfMemory(const char* file, int line, const char* function, Size size = 0) noexcept;
476  };
477 #ifdef _MSC_VER
478 # pragma warning( pop ) // restore old warning state
479 #endif
480 
485  class OPENMS_DLLAPI BufferOverflow :
486  public BaseException
487  {
488 public:
489  BufferOverflow(const char* file, int line, const char* function) noexcept;
490  };
491 
497  class OPENMS_DLLAPI DivisionByZero :
498  public BaseException
499  {
500 public:
501  DivisionByZero(const char* file, int line, const char* function) noexcept;
502  };
503 
509  class OPENMS_DLLAPI OutOfGrid :
510  public BaseException
511  {
512 public:
513  OutOfGrid(const char* file, int line, const char* function) noexcept;
514  };
515 
523  class OPENMS_DLLAPI FileNotFound :
524  public BaseException
525  {
526 public:
527  FileNotFound(const char* file, int line, const char* function, const std::string& filename) noexcept;
528  };
529 
537  class OPENMS_DLLAPI FileNotReadable :
538  public BaseException
539  {
540 public:
541  FileNotReadable(const char* file, int line, const char* function, const std::string& filename) noexcept;
542  };
543 
551  class OPENMS_DLLAPI FileNotWritable :
552  public BaseException
553  {
554 public:
555  FileNotWritable(const char* file, int line, const char* function, const std::string& filename) noexcept;
556  };
557 
566  class OPENMS_DLLAPI FileNameTooLong :
567  public BaseException
568  {
569  public:
570  FileNameTooLong(const char* file, int line, const char* function, const std::string& filename, int max_length) noexcept;
571  };
572 
580  class OPENMS_DLLAPI IOException :
581  public BaseException
582  {
583 public:
584  IOException(const char* file, int line, const char* function, const std::string& filename) 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 
662  class OPENMS_DLLAPI ElementNotFound :
663  public BaseException
664  {
665 public:
666  ElementNotFound(const char* file, int line, const char* function, const std::string& element) noexcept;
667  };
668 
676  class OPENMS_DLLAPI UnableToFit :
677  public BaseException
678  {
679 public:
680  UnableToFit(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
681  };
682 
691  class OPENMS_DLLAPI UnableToCalibrate :
692  public BaseException
693  {
694 public:
695  UnableToCalibrate(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
696  };
697 
705  class OPENMS_DLLAPI DepletedIDPool :
706  public BaseException
707  {
708 public:
709  DepletedIDPool(const char* file, int line, const char* function, const std::string& name, const std::string& message) noexcept;
710  };
711 
712  } // namespace Exception
713 
735  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Exception::BaseException& e);
736 
737 } // namespace OPENMS
738 
OpenMS::Exception::Postcondition
Postcondition failed exception.
Definition: Exception.h:180
OpenMS::Exception::InvalidIterator
Invalid iterator exception.
Definition: Exception.h:407
OpenMS::Exception::FileNameTooLong
Filename is too long to be writable/readable by the filesystem.
Definition: Exception.h:566
OpenMS::Exception::SizeUnderflow
UInt underflow exception.
Definition: Exception.h:235
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:147
OpenMS::Exception::InvalidSize
Invalid UInt exception.
Definition: Exception.h:303
OpenMS::Exception::BaseException::what_
std::string what_
A more detailed description of the exception's cause.
Definition: Exception.h:156
OpenMS::Exception::InvalidValue
Invalid value exception.
Definition: Exception.h:335
OpenMS::Exception::IllegalTreeOperation
Illegal tree operation exception.
Definition: Exception.h:450
OpenMS::Exception::OutOfMemory
Out of memory exception.
Definition: Exception.h:471
OpenMS::Exception::Precondition
Precondition failed exception.
Definition: Exception.h:166
OpenMS::Exception::FileNotFound
File not found exception.
Definition: Exception.h:523
OpenMS::Exception::ConversionError
Invalid conversion exception.
Definition: Exception.h:362
OpenMS::Exception::InvalidRange
Invalid range exception.
Definition: Exception.h:285
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:509
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:347
OpenMS::Exception::DepletedIDPool
Exception used if no more unique document ID's can be drawn from ID pool.
Definition: Exception.h:705
OpenMS::Exception::OutOfRange
Out of range exception.
Definition: Exception.h:319
OpenMS::Exception::DivisionByZero
Division by zero error exception.
Definition: Exception.h:497
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Exception::NullPointer
Null pointer argument is invalid exception.
Definition: Exception.h:393
OpenMS::Exception::FailedAPICall
A call to an external library (other than OpenMS) went wrong.
Definition: Exception.h:271
OpenMS::Exception::BufferOverflow
Buffer overflow exception.
Definition: Exception.h:485
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:150
OpenMS::Exception::BaseException
Exception base class.
Definition: Exception.h:89
OpenMS::Exception::IOException
General IOException.
Definition: Exception.h:580
OpenMS::Exception::NotImplemented
Not implemented exception.
Definition: Exception.h:436
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:153
OpenMS::Exception::IndexOverflow
Int overflow exception.
Definition: Exception.h:254
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::Exception::ParseError
Parse Error exception.
Definition: Exception.h:622
OpenMS::Exception::IncompatibleIterators
Incompatible iterator exception.
Definition: Exception.h:422
OpenMS::Exception::FileNotWritable
File not writable exception.
Definition: Exception.h:551
OpenMS::Exception::BaseException::file_
const char * file_
The source file the exception was thrown in.
Definition: Exception.h:144
OpenMS::Exception::MissingInformation
Not all required information provided.
Definition: Exception.h:195
OpenMS::Exception::ElementNotFound
Element could not be found exception.
Definition: Exception.h:662
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:676
OpenMS::Exception::FileNotReadable
File not readable exception.
Definition: Exception.h:537
OpenMS::Exception::IllegalSelfOperation
Illegal self operation exception.
Definition: Exception.h:378
OpenMS::Exception::UnableToCalibrate
Exception used if an error occurred while calibrating a dataset.
Definition: Exception.h:691
OpenMS::Exception::IndexUnderflow
Int underflow exception.
Definition: Exception.h:216