Doc: Update namespace of extensions
[shapes.git] / source / shapesexceptions.h
blob57bd2659b06a4dc38a22bdf8038b4c33283f6607
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2009, 2015 Henrik Tidefelt
19 #pragma once
21 #include "Shapes_Ast_decls.h"
22 #include "Shapes_Lang_decls.h"
23 #include "Shapes_Kernel_decls.h"
24 #include "Shapes_Exceptions_decls.h"
26 #include "sourcelocation.h"
27 #include "identifier.h"
28 #include "exitcodes.h"
29 #include "methodid.h"
30 #include "simplepdfo.h"
31 #include "strrefdup.h" // this is not needed in this file, but it is convenient to get these declarations for users of this file.
32 #include "pdfversion.h"
34 #include <exception>
35 #include <iostream>
36 #include <sstream>
37 #include <list>
38 #include <set>
39 #include <map>
42 namespace Shapes
45 namespace Exceptions
47 extern const std::string additionalLinesPrefix;
49 class Exception
51 public:
52 Exception( );
53 virtual ~Exception( );
54 virtual void display( std::ostream & os ) const = 0;
55 virtual Interaction::ExitCode exitCode( ) const = 0;
56 static const char * locsep;
59 class NotImplemented : public Exception
61 const char * functionality;
62 public:
63 NotImplemented( const char * _functionality );
64 virtual ~NotImplemented( );
65 virtual void display( std::ostream & os ) const;
66 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_NOT_IMPLEMENTED; }
69 class StaticInconsistency : public Exception
71 protected:
72 Ast::SourceLocation primaryLoc_;
73 public:
74 StaticInconsistency( Ast::SourceLocation primaryLoc ) : primaryLoc_( primaryLoc ) { }
75 virtual ~StaticInconsistency( ) { }
76 const Ast::SourceLocation & loc( ) const { return primaryLoc_; }
77 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_USER_ERROR; }
80 class PostCondition : public Exception
82 protected:
83 Ast::SourceLocation primaryLoc_;
84 public:
85 PostCondition( Ast::SourceLocation primaryLoc ) : primaryLoc_( primaryLoc ) { }
86 virtual ~PostCondition( ) { }
87 const Ast::SourceLocation & loc( ) const { return primaryLoc_; }
88 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_USER_ERROR; }
91 class MiscellaneousStaticInconsistency : public StaticInconsistency
93 RefCountPtr< const char > msg_;
94 public:
95 MiscellaneousStaticInconsistency( const Ast::SourceLocation & loc, RefCountPtr< const char > msg );
96 virtual ~MiscellaneousStaticInconsistency( );
97 virtual void display( std::ostream & os ) const;
100 class NamespaceDirectoryError : public StaticInconsistency
102 RefCountPtr< const char > msg_;
103 public:
104 NamespaceDirectoryError( const Ast::SourceLocation & loc, RefCountPtr< const char > msg );
105 virtual ~NamespaceDirectoryError( );
106 virtual void display( std::ostream & os ) const;
109 class AmbiguousNamespaceDirectory : public StaticInconsistency
111 std::string previousName_;
112 std::string currentDir_;
113 public:
114 AmbiguousNamespaceDirectory( const std::string & previousName, const std::string & currentDir );
115 virtual ~AmbiguousNamespaceDirectory( );
116 virtual void display( std::ostream & os ) const;
119 class NamespaceDirectoryLookupError : public StaticInconsistency
121 public:
122 enum Type{ NOT_FOUND, WRONG_TYPE, GLOBAL };
123 private:
124 Type type_;
125 Ast::NamespacePath namespacePath_;
126 public:
127 NamespaceDirectoryLookupError( const Ast::SourceLocation & loc, Type type, const Ast::NamespacePath::const_iterator & nsBegin, const Ast::NamespacePath::const_iterator & nsEnd );
128 NamespaceDirectoryLookupError( Type type, const Ast::NamespacePath::const_iterator & nsBegin, const Ast::NamespacePath::const_iterator & nsEnd );
129 virtual ~NamespaceDirectoryLookupError( );
130 virtual void display( std::ostream & os ) const;
133 class NamespaceDirectoryFileError : public StaticInconsistency
135 public:
136 enum Type{ NOT_FOUND, WRONG_TYPE };
137 private:
138 Type type_;
139 Ast::NamespacePath namespacePath_;
140 std::string filename_;
141 public:
142 NamespaceDirectoryFileError( const Ast::SourceLocation & loc, Type type, const Ast::NamespacePath & namespacePath, const std::string & filename );
143 NamespaceDirectoryFileError( Type type, const Ast::NamespacePath & namespacePath, const std::string & filename );
144 virtual ~NamespaceDirectoryFileError( );
145 virtual void display( std::ostream & os ) const;
148 class NamespaceDirectoryInvalidEntries : public StaticInconsistency
150 RefCountPtr< const Ast::NamespacePath > namespacePath_;
151 std::set< std::string > invalidEntries_;
152 public:
153 NamespaceDirectoryInvalidEntries( const RefCountPtr< const Ast::NamespacePath > & namespacePath, const std::set< std::string > & invalidEntries );
154 virtual ~NamespaceDirectoryInvalidEntries( );
155 virtual void display( std::ostream & os ) const;
158 class NamespaceDirectoryCircularOrdering : public StaticInconsistency
160 RefCountPtr< const Ast::NamespacePath > namespacePath_;
161 std::string cycleEntry_;
162 public:
163 NamespaceDirectoryCircularOrdering( const RefCountPtr< const Ast::NamespacePath > & namespacePath, const std::string & cycleEntry );
164 virtual ~NamespaceDirectoryCircularOrdering( );
165 virtual void display( std::ostream & os ) const;
168 class ScannerError : public StaticInconsistency
170 RefCountPtr< const char > msg_;
171 public:
172 ScannerError( const Ast::SourceLocation & loc, RefCountPtr< const char > msg );
173 virtual ~ScannerError( );
174 virtual void display( std::ostream & os ) const;
177 class ParserError : public StaticInconsistency
179 RefCountPtr< const char > msg_;
180 bool justAWarning_;
181 public:
182 ParserError( const Ast::SourceLocation & loc, RefCountPtr< const char > msg, bool justAWarning = false );
183 virtual ~ParserError( );
184 virtual void display( std::ostream & os ) const;
187 class MemberAlsoAbstract : public StaticInconsistency
189 Ast::SourceLocation memberLoc;
190 const char * id;
191 Ast::SourceLocation abstractLoc;
192 public:
193 MemberAlsoAbstract( const Ast::SourceLocation & _memberLoc, const char * _id, const Ast::SourceLocation & _abstractLoc );
194 virtual ~MemberAlsoAbstract( );
195 virtual void display( std::ostream & os ) const;
198 class MemberAlreadyDeclared : public StaticInconsistency
200 Ast::SourceLocation memberLoc;
201 const char * id;
202 Ast::SourceLocation oldLoc;
203 public:
204 MemberAlreadyDeclared( const Ast::SourceLocation & _memberLoc, const char * _id, const Ast::SourceLocation & _oldLoc );
205 virtual ~MemberAlreadyDeclared( );
206 virtual void display( std::ostream & os ) const;
209 class PublicGetSetInNonfinalClass : public StaticInconsistency
211 Ast::SourceLocation memberLoc;
212 const char * id;
213 public:
214 PublicGetSetInNonfinalClass( const Ast::SourceLocation & _memberLoc, const char * _id );
215 virtual ~PublicGetSetInNonfinalClass( );
216 virtual void display( std::ostream & os ) const;
219 class TransformingMemberInNonfinalClass : public StaticInconsistency
221 Ast::SourceLocation memberLoc;
222 const char * id;
223 public:
224 TransformingMemberInNonfinalClass( const Ast::SourceLocation & _memberLoc, const char * _id );
225 virtual ~TransformingMemberInNonfinalClass( );
226 virtual void display( std::ostream & os ) const;
229 class RepeatedFormal : public StaticInconsistency
231 const char * id;
232 public:
233 RepeatedFormal( const Ast::SourceLocation & Loc, const char * _id );
234 virtual ~RepeatedFormal( );
235 virtual void display( std::ostream & os ) const;
238 class StateUninitializedUse : public StaticInconsistency
240 const Ast::PlacedIdentifier * id_;
241 const Ast::Node * decl_;
242 public:
243 StateUninitializedUse( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier * id, const Ast::Node * decl );
244 virtual ~StateUninitializedUse( );
245 virtual void display( std::ostream & os ) const;
248 class IllegalFreeStates : public StaticInconsistency
250 Ast::StateIDSet * freeStates_;
251 const char * reason_;
252 public:
253 IllegalFreeStates( const Ast::SourceLocation & loc, Ast::StateIDSet * freeStates, const char * reason );
254 virtual ~IllegalFreeStates( );
255 virtual void display( std::ostream & os ) const;
258 class FreeStateIsAlsoPassed : public StaticInconsistency
260 Ast::StateID stateID_;
261 public:
262 FreeStateIsAlsoPassed( const Ast::SourceLocation & loc, Ast::StateID stateID );
263 virtual ~FreeStateIsAlsoPassed( );
264 virtual void display( std::ostream & os ) const;
267 class RepeatedStateArgument : public StaticInconsistency
269 RefCountPtr< Ast::StateIDSet > passedStates_;
270 public:
271 RepeatedStateArgument( const Ast::SourceLocation & loc, const RefCountPtr< Ast::StateIDSet > & passedStates );
272 virtual ~RepeatedStateArgument( );
273 virtual void display( std::ostream & os ) const;
276 class PassingStateOut : public StaticInconsistency
278 const char * id_;
279 public:
280 PassingStateOut( const Ast::SourceLocation & loc, const char * id );
281 virtual ~PassingStateOut( );
282 virtual void display( std::ostream & os ) const;
285 class IntroducingExisting : public StaticInconsistency
287 Ast::PlacedIdentifier id_;
288 public:
289 IntroducingExisting( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id );
290 virtual ~IntroducingExisting( );
291 virtual void display( std::ostream & os ) const;
294 class NamespaceAliasCollision : public StaticInconsistency
296 const Ast::IdentifierTree * tree_;
297 const char * name_;
298 public:
299 NamespaceAliasCollision( const Ast::SourceLocation & loc, const Ast::IdentifierTree * tree, const char * name );
300 virtual ~NamespaceAliasCollision( );
301 virtual void display( std::ostream & os ) const;
304 class EncapsulationIntroducingExisting : public StaticInconsistency
306 const char * id_;
307 public:
308 EncapsulationIntroducingExisting( const Ast::SourceLocation & loc, const char * id );
309 virtual ~EncapsulationIntroducingExisting( );
310 virtual void display( std::ostream & os ) const;
313 class EncapsulationNamespaceAliasCollision : public StaticInconsistency
315 const char * id_;
316 public:
317 EncapsulationNamespaceAliasCollision( const Ast::SourceLocation & loc, const char * id );
318 virtual ~EncapsulationNamespaceAliasCollision( );
319 virtual void display( std::ostream & os ) const;
322 class FreezingUndefined : public StaticInconsistency
324 Ast::PlacedIdentifier id_;
325 public:
326 FreezingUndefined( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id );
327 virtual ~FreezingUndefined( );
328 virtual void display( std::ostream & os ) const;
331 class UndefinedNamespace : public StaticInconsistency
333 Ast::NamespaceReference id_;
334 public:
335 UndefinedNamespace( const Ast::SourceLocation & loc, const Ast::NamespaceReference & id );
336 virtual ~UndefinedNamespace( );
337 virtual void display( std::ostream & os ) const;
340 class ExpectedImmediate : public StaticInconsistency
342 Ast::SourceLocation loc;
343 public:
344 ExpectedImmediate( const Ast::SourceLocation & _loc );
345 virtual ~ExpectedImmediate( );
346 virtual void display( std::ostream & os ) const;
349 class IllegalImperative : public StaticInconsistency
351 Ast::SourceLocation loc;
352 public:
353 IllegalImperative( const Ast::SourceLocation & _loc );
354 virtual ~IllegalImperative( );
355 virtual void display( std::ostream & os ) const;
358 class FileReadOpenError : public Exception
360 public:
361 enum Type{ OPEN, STAT };
362 private:
363 Ast::SourceLocation loc;
364 RefCountPtr< const char > filename;
365 Type type;
366 const std::string * sourceDir_;
367 const std::list< std::string > * searchPath_;
368 public:
369 FileReadOpenError( const Ast::SourceLocation & _loc, RefCountPtr< const char > _filename, const std::string * sourceDir, const std::list< std::string > * searchPath, Type _type = OPEN );
370 virtual ~FileReadOpenError( );
371 virtual void display( std::ostream & os ) const;
372 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_INPUT_FILE_ERROR; }
375 class FileWriteOpenError : public Exception
377 private:
378 Ast::SourceLocation loc;
379 RefCountPtr< const char > filename;
380 const char * purpose_;
381 public:
382 FileWriteOpenError( const Ast::SourceLocation & _loc, RefCountPtr< const char > _filename, const char * purpose = 0 );
383 virtual ~FileWriteOpenError( );
384 virtual void display( std::ostream & os ) const;
385 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_OUTPUT_FILE_ERROR; }
388 class TeXSetupTooLate : public Exception
390 Ast::SourceLocation loc;
391 public:
392 TeXSetupTooLate( const Ast::SourceLocation & _loc );
393 virtual ~TeXSetupTooLate( );
394 virtual void display( std::ostream & os ) const;
395 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_USER_ERROR; }
398 class EmptyFinalPicture : public Exception
400 public:
401 EmptyFinalPicture( );
402 virtual ~EmptyFinalPicture( );
403 virtual void display( std::ostream & os ) const;
404 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_USER_ERROR; }
407 class RuntimeError : public Exception
409 Ast::SourceLocation loc_;
410 public:
411 RuntimeError( const Ast::SourceLocation & loc );
412 RuntimeError( Ast::Expression * expr );
413 const Ast::SourceLocation & getLoc( ) const;
414 virtual ~RuntimeError( );
415 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_USER_ERROR; } /* This should be overridden when apropriate! */
418 class CatchableError : public RuntimeError
420 public:
421 CatchableError( const Ast::SourceLocation & loc );
422 CatchableError( Ast::Expression * expr );
423 virtual ~CatchableError( );
424 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const = 0;
427 class UncaughtError : public RuntimeError
429 RefCountPtr< const Lang::Exception > ball_;
430 public:
431 UncaughtError( const RefCountPtr< const Lang::Exception > & ball );
432 virtual ~UncaughtError( );
433 virtual void display( std::ostream & os ) const;
434 virtual Interaction::ExitCode exitCode( ) const;
435 const RefCountPtr< const Lang::Exception > & ball( ) const { return ball_; }
438 class UserError : public CatchableError
440 RefCountPtr< const Lang::Symbol > kind_;
441 RefCountPtr< const Lang::String > source_;
442 RefCountPtr< const Lang::Value > details_;
443 RefCountPtr< const char > message_;
444 public:
445 UserError( const RefCountPtr< const Lang::Symbol > & kind, const RefCountPtr< const Lang::String > & source, const RefCountPtr< const Lang::Value > & details, const RefCountPtr< const char > & message );
446 virtual ~UserError( );
447 virtual void display( std::ostream & os ) const;
448 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
449 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_USER_DETECTED_ERROR; }
452 class InternalError : public RuntimeError
454 const char * msg_;
455 RefCountPtr< const char > msgMem_;
456 bool justAWarning_;
457 public:
458 InternalError( const Ast::SourceLocation & loc, RefCountPtr< const char > msg, bool justAWarning = false );
459 InternalError( const Ast::SourceLocation & loc, const char * msg, bool justAWarning = false );
460 InternalError( RefCountPtr< const char > msg, bool justAWarning = false );
461 InternalError( const char * msg, bool justAWarning = false );
462 InternalError( const std::ostringstream & msg, bool justAWarning = false );
463 virtual ~InternalError( );
464 virtual void display( std::ostream & os ) const;
465 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_INTERNAL_ERROR; }
468 class ExternalError : public CatchableError
470 const char * msg_;
471 RefCountPtr< const char > msgMem_;
472 bool justAWarning_;
473 public:
474 ExternalError( RefCountPtr< const char > msg, bool justAWarning = false );
475 ExternalError( const char * msg, bool justAWarning = false );
476 virtual ~ExternalError( );
477 virtual void display( std::ostream & os ) const;
478 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
479 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_EXTERNAL_ERROR; }
480 ExternalError * cloneTyped( ) const;
483 class TeXSetupHasChanged : public InternalError
485 public:
486 TeXSetupHasChanged( );
487 virtual ~TeXSetupHasChanged( );
490 class MiscellaneousRequirement : public CatchableError
492 const char * msg_;
493 RefCountPtr< const char > msgMem_;
494 public:
495 MiscellaneousRequirement( RefCountPtr< const char > msg );
496 MiscellaneousRequirement( const char * msg );
497 virtual ~MiscellaneousRequirement( );
498 virtual void display( std::ostream & os ) const;
499 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
502 class HandlerError : public CatchableError
504 RefCountPtr< const char > msg;
505 public:
506 HandlerError( RefCountPtr< const char > _msg );
507 HandlerError( const char * _msg );
508 virtual ~HandlerError( );
509 virtual void display( std::ostream & os ) const;
510 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
513 class PDFVersionError : public CatchableError
515 SimplePDF::PDF_Version::Version version_;
516 SimplePDF::PDF_Version::Version required_;
517 RefCountPtr< const char > msgMem_;
518 const char * msg_;
519 bool justAWarning_;
520 public:
521 PDFVersionError( SimplePDF::PDF_Version::Version version, SimplePDF::PDF_Version::Version required, const RefCountPtr< const char > & msg, bool justAWarning = false );
522 PDFVersionError( SimplePDF::PDF_Version::Version version, SimplePDF::PDF_Version::Version required, const char * msg, bool justAWarning = false );
523 virtual ~PDFVersionError( );
524 virtual void display( std::ostream & os ) const;
525 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
528 class RedefiningLexical : public RuntimeError
530 Ast::PlacedIdentifier id;
531 public:
532 RedefiningLexical( const Ast::PlacedIdentifier & _id );
533 virtual ~RedefiningLexical( );
534 virtual void display( std::ostream & os ) const;
537 class RedefiningDynamic : public RuntimeError
539 Ast::PlacedIdentifier id;
540 public:
541 RedefiningDynamic( const Ast::PlacedIdentifier & _id );
542 virtual ~RedefiningDynamic( );
543 virtual void display( std::ostream & os ) const;
546 class TypeMismatch : public RuntimeError
548 const char * hint_;
549 RefCountPtr< const char > valueType;
550 RefCountPtr< const char > expectedType;
551 public:
552 TypeMismatch( const Ast::SourceLocation & loc, const char * hint, RefCountPtr< const char > _valueType, RefCountPtr< const char > _expectedType );
553 TypeMismatch( const Ast::SourceLocation & loc, RefCountPtr< const char > _valueType, RefCountPtr< const char > _expectedType );
554 virtual ~TypeMismatch( );
555 virtual void display( std::ostream & os ) const;
558 class NonObjectMemberAssignment : public RuntimeError
560 RefCountPtr< const char > valueType;
561 public:
562 NonObjectMemberAssignment( const Ast::SourceLocation & _loc, RefCountPtr< const char > _valueType );
563 virtual ~NonObjectMemberAssignment( );
564 virtual void display( std::ostream & os ) const;
567 class ElementaryWithout : public RuntimeError
569 public:
570 enum Kind{ VALUE, STATE };
571 enum Ref{ FIELD, MUTATOR };
572 private:
573 Kind kind_;
574 Ref ref_;
575 RefCountPtr< const char > valueType;
576 public:
577 ElementaryWithout( Kind kind, Ref ref, RefCountPtr< const char > _valueType );
578 virtual ~ElementaryWithout( );
579 virtual void display( std::ostream & os ) const;
582 class NonExistentMember : public RuntimeError
584 RefCountPtr< const char > valueType;
585 const char * fieldID;
586 public:
587 NonExistentMember( RefCountPtr< const char > _valueType, const char * _fieldID );
588 virtual ~NonExistentMember( );
589 virtual void display( std::ostream & os ) const;
592 class NonExistentMutator : public RuntimeError
594 RefCountPtr< const char > valueType;
595 const char * mutatorID;
596 public:
597 NonExistentMutator( RefCountPtr< const char > _valueType, const char * _mutatorID );
598 virtual ~NonExistentMutator( );
599 virtual void display( std::ostream & os ) const;
602 class NonExistentPosition : public RuntimeError
604 size_t pos_;
605 size_t maxPos_;
606 public:
607 NonExistentPosition( size_t pos, size_t maxPos );
608 virtual ~NonExistentPosition( );
609 virtual void display( std::ostream & os ) const;
612 class UnaryPrefixNotApplicable : public RuntimeError
614 const Ast::Expression * expr;
615 RefCountPtr< const char > valueType;
616 const char * operatorSymbol;
617 public:
618 UnaryPrefixNotApplicable( const Ast::SourceLocation & _loc, const Ast::Expression * _expr, RefCountPtr< const char > _valueType );
619 virtual ~UnaryPrefixNotApplicable( );
620 void setOperatorSymbol( const char * _operatorSymbol );
621 virtual void display( std::ostream & os ) const;
624 class UnaryPostfixNotApplicable : public RuntimeError
626 const Ast::Expression * expr;
627 RefCountPtr< const char > valueType;
628 const char * operatorSymbol;
629 public:
630 UnaryPostfixNotApplicable( const Ast::SourceLocation & _loc, const Ast::Expression * _expr, RefCountPtr< const char > _valueType );
631 virtual ~UnaryPostfixNotApplicable( );
632 void setOperatorSymbol( const char * _operatorSymbol );
633 virtual void display( std::ostream & os ) const;
636 class BinaryInfixNotApplicable : public RuntimeError
638 const Ast::Expression * expr1;
639 RefCountPtr< const char > valueType1;
640 const Ast::Expression * expr2;
641 RefCountPtr< const char > valueType2;
642 const char * operatorSymbol;
643 public:
644 BinaryInfixNotApplicable( const Ast::SourceLocation & _loc, const Ast::Expression * _expr1, RefCountPtr< const char > _valueType1, const Ast::Expression * _expr2, RefCountPtr< const char > _valueType2 );
645 virtual ~BinaryInfixNotApplicable( );
646 void setOperatorSymbol( const char * _operatorSymbol );
647 virtual void display( std::ostream & os ) const;
650 class LookupUnknown : public StaticInconsistency
652 Ast::Identifier id_;
653 Ast::Identifier::Type type_;
654 public:
655 LookupUnknown( const Ast::SourceLocation & loc, const Ast::Identifier & id, Ast::Identifier::Type type );
656 virtual ~LookupUnknown( );
657 virtual void display( std::ostream & os ) const;
660 class LookupUnknownPrivateAlias : public StaticInconsistency
662 Ast::PlacedIdentifier id_;
663 Ast::Identifier::Type type_;
664 public:
665 LookupUnknownPrivateAlias( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id, Ast::Identifier::Type type );
666 virtual ~LookupUnknownPrivateAlias( );
667 virtual void display( std::ostream & os ) const;
670 class StateBeyondFunctionBoundary : public StaticInconsistency
672 Ast::Identifier id_;
673 public:
674 StateBeyondFunctionBoundary( const Ast::SourceLocation & loc, const Ast::Identifier & id );
675 virtual ~StateBeyondFunctionBoundary( );
676 virtual void display( std::ostream & os ) const;
679 class IntroducingExistingUnit : public StaticInconsistency
681 RefCountPtr< const char > id;
682 public:
683 IntroducingExistingUnit( const Ast::SourceLocation & _loc, RefCountPtr< const char > _id );
684 virtual ~IntroducingExistingUnit( );
685 virtual void display( std::ostream & os ) const;
688 class LookupUnknownUnit : public StaticInconsistency
690 RefCountPtr< const char > id;
691 public:
692 LookupUnknownUnit( const Ast::SourceLocation & _loc, RefCountPtr< const char > _id );
693 virtual ~LookupUnknownUnit( );
694 virtual void display( std::ostream & os ) const;
697 class OutOfRange : public CatchableError
699 const char * msg_;
700 RefCountPtr< const char > msgMem_;
701 public:
702 OutOfRange( RefCountPtr< const char > msg );
703 OutOfRange( const char * msg );
704 OutOfRange( const Ast::SourceLocation & _loc, RefCountPtr< const char > msg );
705 OutOfRange( const Ast::SourceLocation & _loc, const char * msg );
706 virtual ~OutOfRange( );
707 virtual void display( std::ostream & os ) const;
708 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
711 class FontProblem : public CatchableError
713 RefCountPtr< const Lang::Symbol > PostScript_name_;
714 const char * msg_;
715 RefCountPtr< const char > msgMem_;
716 bool justAWarning_;
717 public:
718 FontProblem( const RefCountPtr< const Lang::Symbol > & PostScript_name, RefCountPtr< const char > msg, bool justAWarning = false );
719 FontProblem( const RefCountPtr< const Lang::Symbol > & PostScript_name, const char * msg, bool justAWarning = false );
720 FontProblem( const RefCountPtr< const Lang::Symbol > & PostScript_name, const Ast::SourceLocation & _loc, RefCountPtr< const char > msg, bool justAWarning = false );
721 FontProblem( const RefCountPtr< const Lang::Symbol > & PostScript_name, const Ast::SourceLocation & _loc, const char * msg, bool justAWarning = false );
722 virtual ~FontProblem( );
723 virtual void display( std::ostream & os ) const;
724 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
727 class NonVoidStatement : public RuntimeError
729 RefCountPtr< const Lang::Value > val_;
730 public:
731 NonVoidStatement( const Ast::SourceLocation & loc, RefCountPtr< const Lang::Value > val );
732 virtual ~NonVoidStatement( );
733 virtual void display( std::ostream & os ) const;
736 class UserArityMismatch : public RuntimeError
738 public:
739 enum Type{ VARIABLE, STATE };
740 private:
741 const Ast::SourceLocation formalsLoc;
742 const size_t functionArity;
743 const size_t callArity;
744 const Type type_;
745 public:
746 UserArityMismatch( const Ast::SourceLocation _formalsLoc, size_t _functionArity, size_t _callArity, const Type type );
747 virtual ~UserArityMismatch( );
748 virtual void display( std::ostream & os ) const;
751 class SinkRequired : public RuntimeError
753 private:
754 const Ast::SourceLocation formalsLoc_;
755 const size_t formalsArity_;
756 const size_t callArity_;
757 public:
758 SinkRequired( const Ast::SourceLocation formalsLoc, size_t formalsArity, size_t callArity );
759 virtual ~SinkRequired( );
760 virtual void display( std::ostream & os ) const;
763 class NamedFormalMismatch : public RuntimeError
765 public:
766 enum Type{ VARIABLE, STATE };
767 private:
768 const Ast::SourceLocation formalsLoc;
769 RefCountPtr< const char > name;
770 Type type_;
771 public:
772 NamedFormalMismatch( const Ast::SourceLocation _formalsLoc, RefCountPtr< const char > _name, Type type );
773 virtual ~NamedFormalMismatch( );
774 virtual void display( std::ostream & os ) const;
777 class NamedFormalAlreadySpecified : public RuntimeError
779 public:
780 enum Type{ VARIABLE, STATE };
781 private:
782 const Ast::SourceLocation formalsLoc;
783 RefCountPtr< const char > name;
784 size_t pos;
785 Type type_;
786 public:
787 NamedFormalAlreadySpecified( const Ast::SourceLocation _formalsLoc, RefCountPtr< const char > _name, size_t _pos, Type type );
788 virtual ~NamedFormalAlreadySpecified( );
789 virtual void display( std::ostream & os ) const;
792 class MissingArguments : public RuntimeError
794 const Ast::SourceLocation formalsLoc_;
795 RefCountPtr< const std::map< size_t, RefCountPtr< const char > > > missingVariables_;
796 RefCountPtr< const std::map< size_t, RefCountPtr< const char > > > missingStates_;
797 public:
798 MissingArguments( const Ast::SourceLocation formalsLoc, std::map< size_t, RefCountPtr< const char > > * missingVariables, std::map< size_t, RefCountPtr< const char > > * missingStates );
799 ~MissingArguments( );
800 virtual void display( std::ostream & os ) const;
803 class CoreArityMismatch : public RuntimeError
805 const char * title;
806 RefCountPtr< const char > titleMem;
807 const size_t functionArityLow;
808 const size_t functionArityHigh;
809 const size_t callArity;
810 public:
811 CoreArityMismatch( const char * _title, size_t _functionArity, size_t _callArity );
812 CoreArityMismatch( const char * _title, size_t _functionArityLow, size_t _functionArityHigh, size_t _callArity );
813 CoreArityMismatch( const RefCountPtr< const char > & _title, size_t _functionArity, size_t _callArity );
814 CoreArityMismatch( const RefCountPtr< const char > & _title, size_t _functionArityLow, size_t _functionArityHigh, size_t _callArity );
815 virtual ~CoreArityMismatch( );
816 virtual void display( std::ostream & os ) const;
819 class CoreNoNamedFormals : public RuntimeError
821 const char * title;
822 RefCountPtr< const char > titleMem;
823 public:
824 CoreNoNamedFormals( const char * _title );
825 CoreNoNamedFormals( const RefCountPtr< const char > & _title );
826 virtual ~CoreNoNamedFormals( );
827 virtual void display( std::ostream & os ) const;
830 class CoreTypeMismatch : public RuntimeError
832 const char * title_;
833 RefCountPtr< const char > titleMem_;
834 const Ast::SourceLocation argLoc_;
835 RefCountPtr< const char > valueType_;
836 RefCountPtr< const char > expectedType_;
837 public:
838 CoreTypeMismatch( const Ast::SourceLocation & callLoc,
839 const char * title,
840 const Ast::SourceLocation & argLoc,
841 RefCountPtr< const char > valueType,
842 RefCountPtr< const char > expectedType );
843 CoreTypeMismatch( const Ast::SourceLocation & callLoc,
844 RefCountPtr< const char > title,
845 const Ast::SourceLocation & argLoc,
846 RefCountPtr< const char > valueType,
847 RefCountPtr< const char > expectedType );
848 CoreTypeMismatch( const Ast::SourceLocation & callLoc,
849 const char * title,
850 Kernel::Arguments & args,
851 size_t argNo,
852 RefCountPtr< const char > expectedType );
853 CoreTypeMismatch( const Ast::SourceLocation & callLoc,
854 RefCountPtr< const char > title,
855 Kernel::Arguments & args,
856 size_t argNo,
857 RefCountPtr< const char > expectedType );
858 virtual ~CoreTypeMismatch( );
859 virtual void display( std::ostream & os ) const;
862 class CoreDynamicTypeMismatch : public RuntimeError
864 const char * title_;
865 RefCountPtr< const char > titleMem_;
866 Ast::PlacedIdentifier id_;
867 RefCountPtr< const char > idMem_;
868 RefCountPtr< const char > valueType_;
869 RefCountPtr< const char > expectedType_;
870 public:
871 CoreDynamicTypeMismatch( const Ast::SourceLocation & callLoc,
872 const char * title,
873 const Ast::PlacedIdentifier & id,
874 RefCountPtr< const char > valueType,
875 RefCountPtr< const char > expectedType );
876 virtual ~CoreDynamicTypeMismatch( );
877 virtual void display( std::ostream & os ) const;
880 class CoreStateTypeMismatch : public RuntimeError
882 const char * title_;
883 RefCountPtr< const char > titleMem_;
884 const Ast::SourceLocation argLoc_;
885 RefCountPtr< const char > valueType_;
886 RefCountPtr< const char > expectedType_;
887 public:
888 CoreStateTypeMismatch( const Ast::SourceLocation & callLoc,
889 const char * title,
890 const Ast::SourceLocation & argLoc,
891 RefCountPtr< const char > valueType,
892 RefCountPtr< const char > expectedType );
893 CoreStateTypeMismatch( const Ast::SourceLocation & callLoc,
894 RefCountPtr< const char > title,
895 const Ast::SourceLocation & argLoc,
896 RefCountPtr< const char > valueType,
897 RefCountPtr< const char > expectedType );
898 CoreStateTypeMismatch( const Ast::SourceLocation & callLoc,
899 const char * title,
900 Kernel::Arguments & args,
901 size_t argNo,
902 RefCountPtr< const char > expectedType );
903 CoreStateTypeMismatch( const Ast::SourceLocation & callLoc,
904 RefCountPtr< const char > title,
905 Kernel::Arguments & args,
906 size_t argNo,
907 RefCountPtr< const char > expectedType );
908 virtual ~CoreStateTypeMismatch( );
909 virtual void display( std::ostream & os ) const;
912 class ContinuationTypeMismatch : public RuntimeError
914 RefCountPtr< const char > valueType_;
915 RefCountPtr< const char > expectedType_;
916 public:
917 ContinuationTypeMismatch( const Kernel::Continuation * locationCont,
918 RefCountPtr< const char > valueType,
919 RefCountPtr< const char > expectedType );
920 virtual ~ContinuationTypeMismatch( );
921 virtual void display( std::ostream & os ) const;
924 class CoreOutOfRange : public CatchableError
926 const char * title_;
927 size_t argNo_;
928 const Ast::SourceLocation argLoc_;
929 const char * msg_;
930 RefCountPtr< const char > msgMem_;
931 public:
932 CoreOutOfRange( const char * title, Kernel::Arguments & args, size_t argNo, RefCountPtr< const char > msg );
933 CoreOutOfRange( const char * title, Kernel::Arguments & args, size_t argNo, const char * msg );
934 virtual ~CoreOutOfRange( );
935 virtual void display( std::ostream & os ) const;
936 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
939 class UserOutOfRange : public CatchableError
941 RefCountPtr< const Lang::Symbol > kind_;
942 RefCountPtr< const Lang::String > source_;
943 RefCountPtr< const Lang::Integer > details_;
944 RefCountPtr< const char > message_;
945 public:
946 UserOutOfRange( const RefCountPtr< const Lang::Symbol > & kind, const RefCountPtr< const Lang::String > & source, const RefCountPtr< const Lang::Integer > & details, const RefCountPtr< const char > & message );
947 virtual ~UserOutOfRange( );
948 virtual void display( std::ostream & os ) const;
949 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
952 class UserTypeMismatch : public CatchableError
954 RefCountPtr< const Lang::Symbol > kind_;
955 RefCountPtr< const Lang::String > source_;
956 RefCountPtr< const Lang::Integer > details_;
957 RefCountPtr< const char > expectedType_;
958 RefCountPtr< const char > valueType_;
959 public:
960 UserTypeMismatch( const RefCountPtr< const Lang::Symbol > & kind, const RefCountPtr< const Lang::String > & source, const RefCountPtr< const Lang::Integer > & details, const RefCountPtr< const char > & expectedType, const RefCountPtr< const char > & valueType );
961 virtual ~UserTypeMismatch( );
962 virtual void display( std::ostream & os ) const;
963 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
966 class CoreRequirement : public CatchableError
968 const char * title_;
969 const char * msg_;
970 RefCountPtr< const char > msgMem_;
971 public:
972 CoreRequirement( RefCountPtr< const char > msg, const char * title, const Ast::SourceLocation & callLoc );
973 CoreRequirement( const char * msg, const char * title, const Ast::SourceLocation & callLoc );
974 virtual ~CoreRequirement( );
975 virtual void display( std::ostream & os ) const;
976 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
979 class BuildRequirement : public CatchableError
981 const char * title_;
982 const char * dependency_;
983 public:
984 BuildRequirement( const char * dependency, const char * title, const Ast::SourceLocation & callLoc );
985 virtual ~BuildRequirement( );
986 virtual void display( std::ostream & os ) const;
987 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
990 class TeXLabelError : public RuntimeError
992 const Ast::SourceLocation strLoc_;
993 bool quoted_;
994 const char * region_;
995 RefCountPtr< const char > summary_;
996 RefCountPtr< const char > details_;
997 public:
998 TeXLabelError( bool quoted, const char * region, RefCountPtr< const char > summary, RefCountPtr< const char > details, const Ast::SourceLocation & strLoc );
999 virtual ~TeXLabelError( );
1000 virtual void display( std::ostream & os ) const;
1001 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_TEX_ERROR; }
1004 class StaticTeXLabelError : public StaticInconsistency
1006 bool quoted_;
1007 const char * region_;
1008 RefCountPtr< const char > summary_;
1009 RefCountPtr< const char > details_;
1010 public:
1011 StaticTeXLabelError( bool quoted, const char * region, RefCountPtr< const char > summary, RefCountPtr< const char > details, const Ast::SourceLocation & strLoc );
1012 virtual ~StaticTeXLabelError( );
1013 virtual void display( std::ostream & os ) const;
1014 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_TEX_ERROR; }
1017 class MultipleDynamicBind : public RuntimeError
1019 const Ast::PlacedIdentifier * id_;
1020 Ast::SourceLocation prevLoc_;
1021 public:
1022 MultipleDynamicBind( const Ast::PlacedIdentifier * id, const Ast::SourceLocation & loc, const Ast::SourceLocation & prevLoc );
1023 virtual ~MultipleDynamicBind( );
1024 virtual void display( std::ostream & os ) const;
1027 class UndefinedEscapeContinuation : public RuntimeError
1029 const char * id_;
1030 public:
1031 UndefinedEscapeContinuation( const char * id, const Ast::SourceLocation & loc );
1032 virtual ~UndefinedEscapeContinuation( );
1033 virtual void display( std::ostream & os ) const;
1036 class DeadStateAccess : public RuntimeError
1038 public:
1039 DeadStateAccess( );
1040 virtual ~DeadStateAccess( );
1041 virtual void display( std::ostream & os ) const;
1044 class UnFreezable : public RuntimeError
1046 public:
1047 UnFreezable( );
1048 virtual ~UnFreezable( );
1049 virtual void display( std::ostream & os ) const;
1052 class UnPeekable : public RuntimeError
1054 public:
1055 UnPeekable( );
1056 virtual ~UnPeekable( );
1057 virtual void display( std::ostream & os ) const;
1060 class UninitializedAccess : public RuntimeError
1062 public:
1063 UninitializedAccess( );
1064 virtual ~UninitializedAccess( );
1065 virtual void display( std::ostream & os ) const;
1068 class DtMinError : public CatchableError
1070 double dt;
1071 public:
1072 DtMinError( double _dt );
1073 virtual ~DtMinError( );
1074 virtual void display( std::ostream & os ) const;
1075 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
1076 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_TOLERANCE_ERROR; }
1079 class AffineTransformKillsPlane : public CatchableError
1081 double sigma2_;
1082 public:
1083 AffineTransformKillsPlane( double sigma2 );
1084 virtual ~AffineTransformKillsPlane( );
1085 virtual void display( std::ostream & os ) const;
1086 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
1089 class MissingFontMetrics : public RuntimeError
1091 RefCountPtr< const char > fontname_;
1092 const std::list< std::string > * searchPath_;
1093 public:
1094 MissingFontMetrics( RefCountPtr< const char > fontname, const std::list< std::string > * searchPath );
1095 virtual ~MissingFontMetrics( );
1096 virtual void display( std::ostream & os ) const;
1097 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_EXTERNAL_ERROR; }
1100 class FontMetricsError : public RuntimeError
1102 RefCountPtr< const char > fontname_;
1103 RefCountPtr< const char > message_;
1104 public:
1105 FontMetricsError( const RefCountPtr< const char > & fontname, const RefCountPtr< const char > & message );
1106 virtual ~FontMetricsError( );
1107 virtual void display( std::ostream & os ) const;
1108 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_EXTERNAL_ERROR; }
1111 class InsertingEmptyPage : public CatchableError
1113 public:
1114 InsertingEmptyPage( const Ast::SourceLocation & loc );
1115 virtual ~InsertingEmptyPage( );
1116 virtual void display( std::ostream & os ) const;
1117 virtual RefCountPtr< const Lang::Exception > clone( const Kernel::ContRef & cont ) const;
1120 class UndefinedCrossRef : public PostCondition
1122 private:
1123 RefCountPtr< const char > ref_;
1124 public:
1125 UndefinedCrossRef( const Ast::SourceLocation & _loc, RefCountPtr< const char > ref );
1126 virtual ~UndefinedCrossRef( );
1127 virtual void display( std::ostream & os ) const;
1130 class InvocationError : public Exception
1132 const char * msg_;
1133 bool justAWarning_;
1134 public:
1135 InvocationError( const char * msg, bool justAWarning = false );
1136 virtual ~InvocationError( );
1137 virtual void display( std::ostream & os ) const;
1138 virtual Interaction::ExitCode exitCode( ) const { return Interaction::EXIT_INVOCATION_ERROR; }
1143 namespace NonLocalExit
1145 // The exceptions in this namespace does not represent ordinary exception conditions in the program.
1146 // Rather, they can be seen as alternative ways for particular functions to return. Thus, the caller
1147 // of such a function shall always take care of any such exceptions, and not let these be passed up.
1148 // For this reason, the classes in this namespace does not inherit from Shapes::Exceptions::Exception.
1150 class NonLocalExitBase
1152 public:
1153 NonLocalExitBase( ){ }
1156 class DynamicBindingNotFound : public NonLocalExitBase
1158 public:
1159 DynamicBindingNotFound( ){ }
1162 class CrossDirectionOfParallel : public NonLocalExitBase
1164 public:
1165 CrossDirectionOfParallel( ){ }
1168 class NotThisType : public NonLocalExitBase
1170 public:
1171 NotThisType( ){ }