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
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 Henrik Tidefelt
19 #include "shapesexceptions.h"
23 #include "functiontypes.h"
25 using namespace Shapes
;
29 const std::string
Exceptions::additionalLinesPrefix
= "| ";
35 void prefixEachLine( const std::string
& prefix
, std::istream
& src
, std::ostream
& dst
);
36 void prefixEachLine( const std::string
& prefix
, const RefCountPtr
< const char > & src
, std::ostream
& dst
);
40 Exceptions::NotImplemented::NotImplemented( const char * _functionality
)
41 : functionality( _functionality
)
44 Exceptions::NotImplemented::~NotImplemented( )
48 Exceptions::NotImplemented::display( std::ostream
& os
) const
50 os
<< "Under construction: " << functionality
<< " is not implemented." << std::endl
;
53 const char * Exceptions::Exception::locsep
= ": ";
55 Exceptions::Exception::Exception( )
58 Exceptions::Exception::~Exception( )
61 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( RefCountPtr
< const char > msg
)
62 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
65 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const char * msg
)
66 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
69 Exceptions::MiscellaneousRequirement::~MiscellaneousRequirement( )
73 Exceptions::MiscellaneousRequirement::display( ostream
& os
) const
75 os
<< "Failed to meet requirement: " << msg_
<< std::endl
;
78 RefCountPtr
< const Lang::Exception
>
79 Exceptions::MiscellaneousRequirement::clone( const Kernel::ContRef
& cont
) const
81 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
82 std::ostringstream os
;
84 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
86 RefCountPtr
< const Lang::String
>( new Lang::String( "(core, generic)", true ) ),
90 this->exitCode( ) ) );
94 Exceptions::HandlerError::HandlerError( RefCountPtr
< const char > _msg
)
95 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg( _msg
)
98 Exceptions::HandlerError::HandlerError( const char * _msg
)
99 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg( strrefdup( _msg
) )
102 Exceptions::HandlerError::~HandlerError( )
106 Exceptions::HandlerError::display( ostream
& os
) const
108 os
<< "Error handler message: " << msg
<< std::endl
;
111 RefCountPtr
< const Lang::Exception
>
112 Exceptions::HandlerError::clone( const Kernel::ContRef
& cont
) const
114 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
115 std::ostringstream os
;
117 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
119 RefCountPtr
< const Lang::String
>( new Lang::String( "(default error handler)", true ) ),
123 this->exitCode( ) ) );
127 Exceptions::MiscellaneousStaticInconsistency::MiscellaneousStaticInconsistency( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _msg
)
128 : Exceptions::StaticInconsistency( loc
), msg( _msg
)
131 Exceptions::MiscellaneousStaticInconsistency::~MiscellaneousStaticInconsistency( )
135 Exceptions::MiscellaneousStaticInconsistency::display( ostream
& os
) const
137 os
<< "Misc error: " << msg
<< std::endl
;
141 Exceptions::ScannerError::ScannerError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _msg
)
142 : Exceptions::StaticInconsistency( loc
), msg( _msg
)
145 Exceptions::ScannerError::~ScannerError( )
149 Exceptions::ScannerError::display( ostream
& os
) const
151 os
<< "Scanner error: " << msg
<< std::endl
;
155 Exceptions::ParserError::ParserError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _msg
)
156 : Exceptions::StaticInconsistency( loc
), msg( _msg
)
159 Exceptions::ParserError::~ParserError( )
163 Exceptions::ParserError::display( ostream
& os
) const
165 os
<< "Parser error: " << msg
<< std::endl
;
169 Exceptions::MemberAlsoAbstract::MemberAlsoAbstract( const Ast::SourceLocation
& _memberLoc
, const char * _id
, const Ast::SourceLocation
& _abstractLoc
)
170 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
), abstractLoc( _abstractLoc
)
173 Exceptions::MemberAlsoAbstract::~MemberAlsoAbstract( )
177 Exceptions::MemberAlsoAbstract::display( ostream
& os
) const
179 os
<< "The member " << id
<< " is also declared abstract, at " << abstractLoc
<< "." << std::endl
;
183 Exceptions::MemberAlreadyDeclared::MemberAlreadyDeclared( const Ast::SourceLocation
& _memberLoc
, const char * _id
, const Ast::SourceLocation
& _oldLoc
)
184 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
), oldLoc( _oldLoc
)
187 Exceptions::MemberAlreadyDeclared::~MemberAlreadyDeclared( )
191 Exceptions::MemberAlreadyDeclared::display( ostream
& os
) const
193 os
<< "The member " << id
<< " has already been declared, at " << oldLoc
<< "." << std::endl
;
197 Exceptions::PublicGetSetInNonfinalClass::PublicGetSetInNonfinalClass( const Ast::SourceLocation
& _memberLoc
, const char * _id
)
198 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
)
201 Exceptions::PublicGetSetInNonfinalClass::~PublicGetSetInNonfinalClass( )
205 Exceptions::PublicGetSetInNonfinalClass::display( ostream
& os
) const
207 os
<< "Only members of final classes may have the public get or set specifier. Member in question: " << id
<< "." << std::endl
;
211 Exceptions::TransformingMemberInNonfinalClass::TransformingMemberInNonfinalClass( const Ast::SourceLocation
& _memberLoc
, const char * _id
)
212 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
)
215 Exceptions::TransformingMemberInNonfinalClass::~TransformingMemberInNonfinalClass( )
219 Exceptions::TransformingMemberInNonfinalClass::display( ostream
& os
) const
221 os
<< "Only members of final classes may have the <transforming> specifier. Member in question: " << id
<< "." << std::endl
;
225 Exceptions::RepeatedFormal::RepeatedFormal( const Ast::SourceLocation
& loc
, const char * _id
)
226 : Exceptions::StaticInconsistency( loc
), id( _id
)
229 Exceptions::RepeatedFormal::~RepeatedFormal( )
233 Exceptions::RepeatedFormal::display( ostream
& os
) const
235 os
<< "Repeated formal: " << id
<< std::endl
;
239 Exceptions::IllegalFreeStates::IllegalFreeStates( const Ast::SourceLocation
& loc
, Ast::StateIDSet
* freeStates
, const char * reason
)
240 : Exceptions::StaticInconsistency( loc
), freeStates_( freeStates
), reason_( reason
)
243 Exceptions::IllegalFreeStates::~IllegalFreeStates( )
247 Exceptions::IllegalFreeStates::display( ostream
& os
) const
249 os
<< "Free states are illegal here (" << reason_
<< "):" ;
250 typedef typeof *freeStates_ SetType
;
251 for( SetType::const_iterator i
= freeStates_
->begin( ); i
!= freeStates_
->end( ); ++i
)
259 Exceptions::FreeStateIsAlsoPassed::FreeStateIsAlsoPassed( const Ast::SourceLocation
& loc
, Ast::StateID stateID
)
260 : Exceptions::StaticInconsistency( loc
), stateID_( stateID
)
263 Exceptions::FreeStateIsAlsoPassed::~FreeStateIsAlsoPassed( )
267 Exceptions::FreeStateIsAlsoPassed::display( ostream
& os
) const
269 os
<< "Non-pure, delayed, expressions may not have free states which are also passed as state arguments in the same non-pure function application. Please consider forcing immediate evaluation." << std::endl
;
273 Exceptions::RepeatedStateArgument::RepeatedStateArgument( const Ast::SourceLocation
& loc
, const RefCountPtr
< Ast::StateIDSet
> & passedStates
)
274 : Exceptions::StaticInconsistency( loc
), passedStates_( passedStates
)
277 Exceptions::RepeatedStateArgument::~RepeatedStateArgument( )
281 Exceptions::RepeatedStateArgument::display( ostream
& os
) const
283 os
<< "Some of these states are being passed in more than one state argument position:" ;
284 typedef typeof *passedStates_ SetType
;
285 for( SetType::const_iterator i
= passedStates_
->begin( ); i
!= passedStates_
->end( ); ++i
)
293 Exceptions::PassingStateOut::PassingStateOut( const Ast::SourceLocation
& loc
, const char * id
)
294 : Exceptions::StaticInconsistency( loc
), id_( id
)
297 Exceptions::PassingStateOut::~PassingStateOut( )
301 Exceptions::PassingStateOut::display( std::ostream
& os
) const
303 os
<< "States may not be returned." << std::endl
;
307 Exceptions::IntroducingExisting::IntroducingExisting( const Ast::SourceLocation
& _loc
, const char * _id
)
308 : Exceptions::StaticInconsistency( _loc
), loc( _loc
), id( _id
)
311 Exceptions::IntroducingExisting::~IntroducingExisting( )
315 Exceptions::IntroducingExisting::display( std::ostream
& os
) const
317 os
<< "The variable " << id
<< " is already introduced in this scope." << std::endl
;
321 Exceptions::ExpectedImmediate::ExpectedImmediate( const Ast::SourceLocation
& _loc
)
322 : Exceptions::StaticInconsistency( _loc
), loc( _loc
)
325 Exceptions::ExpectedImmediate::~ExpectedImmediate( )
329 Exceptions::ExpectedImmediate::display( std::ostream
& os
) const
331 os
<< "It makes no sense to put a pure expression before the end of a code bracket." << std::endl
;
335 Exceptions::IllegalImperative::IllegalImperative( const Ast::SourceLocation
& _loc
)
336 : Exceptions::StaticInconsistency( _loc
), loc( _loc
)
339 Exceptions::IllegalImperative::~IllegalImperative( )
343 Exceptions::IllegalImperative::display( std::ostream
& os
) const
345 os
<< "Imperative expressions are not allowed here." << std::endl
;
349 Exceptions::FreezingUndefined::FreezingUndefined( const Ast::SourceLocation
& _loc
, const char * _id
)
350 : Exceptions::StaticInconsistency( _loc
), loc( _loc
), id( _id
)
353 Exceptions::FreezingUndefined::~FreezingUndefined( )
357 Exceptions::FreezingUndefined::display( std::ostream
& os
) const
359 os
<< "Internal error: The variable " << id
<< " is freezed before it was defined. Either this should be caught by during the parse, or it is due to an error in the setup of the initial environment." << std::endl
;
363 Exceptions::FileReadOpenError::FileReadOpenError( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _filename
, const std::string
* sourceDir
, const std::list
< std::string
> * searchPath
, Type _type
)
364 : loc( _loc
), filename( _filename
), type( _type
), sourceDir_( sourceDir
), searchPath_( searchPath
)
367 Exceptions::FileReadOpenError::~FileReadOpenError( )
371 Exceptions::FileReadOpenError::display( std::ostream
& os
) const
376 os
<< loc
<< locsep
<< "Could not open file: " << filename
;
379 os
<< loc
<< locsep
<< "Could not stat() file: " << filename
;
382 os
<< loc
<< locsep
<< "Internal error when displaying FileReadOpenError on file: " << filename
;
384 if( searchPath_
!= 0 )
386 os
<< " searching \"" ;
387 typedef typeof *searchPath_ ListType
;
388 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
390 if( i
!= searchPath_
->begin( ) )
394 if( sourceDir_
!= 0 && (*i
)[0] != '/' )
406 Exceptions::FileWriteOpenError::FileWriteOpenError( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _filename
, const char * purpose
)
407 : loc( _loc
), filename( _filename
), purpose_( purpose
)
410 Exceptions::FileWriteOpenError::~FileWriteOpenError( )
414 Exceptions::FileWriteOpenError::display( std::ostream
& os
) const
416 os
<< loc
<< locsep
<< "Could not open " ;
421 os
<< " file for write: " << filename
;
426 Exceptions::TeXSetupTooLate::TeXSetupTooLate( const Ast::SourceLocation
& _loc
)
430 Exceptions::TeXSetupTooLate::~TeXSetupTooLate( )
434 Exceptions::TeXSetupTooLate::display( std::ostream
& os
) const
436 os
<< loc
<< locsep
<< "It is too late to make modifications to the TeX context." << std::endl
;
440 Exceptions::EmptyFinalPicture::EmptyFinalPicture( )
443 Exceptions::EmptyFinalPicture::~EmptyFinalPicture( )
447 Exceptions::EmptyFinalPicture::display( std::ostream
& os
) const
449 os
<< "Nothing was ever put in the global #" << Lang::CATALOG_ID
<< " or drawn to the global #" << Lang::CANVAS_ID
<< "." << std::endl
;
453 Exceptions::TeXSetupHasChanged::TeXSetupHasChanged( )
454 : Shapes::Exceptions::InternalError( "The TeX context check failed while loading fresh labels." )
457 Exceptions::TeXSetupHasChanged::~TeXSetupHasChanged( )
461 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
)
462 : Exceptions::RuntimeError( loc
), hint_( 0 ), valueType( _valueType
), expectedType( _expectedType
)
465 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation
& loc
, const char * hint
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
)
466 : Exceptions::RuntimeError( loc
), hint_( hint
), valueType( _valueType
), expectedType( _expectedType
)
469 Exceptions::TypeMismatch::~TypeMismatch( )
473 Exceptions::TypeMismatch::display( std::ostream
& os
) const
477 os
<< hint_
<< ": " ;
479 os
<< "Expected a " << expectedType
<< ", got a " << valueType
<< "." << std::endl
;
482 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const RefCountPtr
< const char > & msg
)
483 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( msg
), msg_( msgMem_
.getPtr( ) )
486 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const char * msg
)
487 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( NullPtr
< const char >( ) ), msg_( msg
)
490 Exceptions::PDFVersionError::~PDFVersionError( )
494 Exceptions::PDFVersionError::display( std::ostream
& os
) const
496 os
<< SimplePDF::PDF_Version::toString( required_
) << " error: " << msg_
<< std::endl
;
499 RefCountPtr
< const Lang::Exception
>
500 Exceptions::PDFVersionError::clone( const Kernel::ContRef
& cont
) const
502 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "PDF_version" ) );
503 std::ostringstream os
;
505 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
507 RefCountPtr
< const Lang::String
>( new Lang::String( "(core PDF backend)", true ) ),
511 this->exitCode( ) ) );
515 Exceptions::RedefiningLexical::RedefiningLexical( const char * _id
)
516 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), id( _id
)
519 Exceptions::RedefiningLexical::~RedefiningLexical( )
523 Exceptions::RedefiningLexical::display( std::ostream
& os
) const
525 os
<< "Redefining " << id
<< std::endl
;
529 Exceptions::RedefiningDynamic::RedefiningDynamic( const char * _id
)
530 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), id( _id
)
533 Exceptions::RedefiningDynamic::~RedefiningDynamic( )
537 Exceptions::RedefiningDynamic::display( std::ostream
& os
) const
539 os
<< "Redefining " << "@" << id
<< std::endl
;
543 Exceptions::NonObjectMemberAssignment::NonObjectMemberAssignment( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _valueType
)
544 : Exceptions::RuntimeError( _loc
), valueType( _valueType
)
547 Exceptions::NonObjectMemberAssignment::~NonObjectMemberAssignment( )
551 Exceptions::NonObjectMemberAssignment::display( std::ostream
& os
) const
553 os
<< "Only object oriented values have fields that can be assigned. This value is of type " << valueType
<< "." << std::endl
;
557 Exceptions::ElementaryWithout::ElementaryWithout( Kind kind
, Ref ref
, RefCountPtr
< const char > _valueType
)
558 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), ref_( ref
), valueType( _valueType
)
561 Exceptions::ElementaryWithout::~ElementaryWithout( )
565 Exceptions::ElementaryWithout::display( std::ostream
& os
) const
577 os
<< " is of the elementary type " << valueType
<< ", which has no " ;
587 os
<< "." << std::endl
;
591 Exceptions::NonExistentPosition::NonExistentPosition( size_t pos
, size_t maxPos
)
592 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), pos_( pos
), maxPos_( maxPos
)
595 Exceptions::NonExistentPosition::~NonExistentPosition( )
599 Exceptions::NonExistentPosition::display( std::ostream
& os
) const
601 os
<< "Referencing field at position " << pos_
<< " is an error since the user struct has only " << maxPos_
<< " ordered fields." << std::endl
;
605 Exceptions::UnaryPrefixNotApplicable::UnaryPrefixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr
, RefCountPtr
< const char > _valueType
)
606 : Exceptions::RuntimeError( _loc
), expr( _expr
), valueType( _valueType
), operatorSymbol( "< ? >" )
609 Exceptions::UnaryPrefixNotApplicable::~UnaryPrefixNotApplicable( )
613 Exceptions::UnaryPrefixNotApplicable::setOperatorSymbol( const char * _operatorSymbol
)
615 operatorSymbol
= _operatorSymbol
;
619 Exceptions::UnaryPrefixNotApplicable::display( std::ostream
& os
) const
624 getLoc( ).copy( & os
);
625 os
<< " not defined for " << valueType
<< " at " << expr
->loc( ) << "." << std::endl
;
629 os
<< "Operator " << operatorSymbol
<< " not defined for " << valueType
<< "." << std::endl
;
634 Exceptions::UnaryPostfixNotApplicable::UnaryPostfixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr
, RefCountPtr
< const char > _valueType
)
635 : Exceptions::RuntimeError( _loc
), expr( _expr
), valueType( _valueType
), operatorSymbol( "< ? >" )
638 Exceptions::UnaryPostfixNotApplicable::~UnaryPostfixNotApplicable( )
642 Exceptions::UnaryPostfixNotApplicable::setOperatorSymbol( const char * _operatorSymbol
)
644 operatorSymbol
= _operatorSymbol
;
648 Exceptions::UnaryPostfixNotApplicable::display( std::ostream
& os
) const
653 getLoc( ).copy( & os
);
654 os
<< " not defined for " << valueType
<< " at " << expr
->loc( ) << "." << std::endl
;
658 os
<< "Operator " << operatorSymbol
<< " not defined for " << valueType
<< "." << std::endl
;
663 Exceptions::BinaryInfixNotApplicable::BinaryInfixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr1
, RefCountPtr
< const char > _valueType1
, const Ast::Expression
* _expr2
, RefCountPtr
< const char > _valueType2
)
664 : Exceptions::RuntimeError( _loc
), expr1( _expr1
), valueType1( _valueType1
), expr2( _expr2
), valueType2( _valueType2
), operatorSymbol( "< ? >" )
667 Exceptions::BinaryInfixNotApplicable::~BinaryInfixNotApplicable( )
671 Exceptions::BinaryInfixNotApplicable::setOperatorSymbol( const char * _operatorSymbol
)
673 operatorSymbol
= _operatorSymbol
;
677 Exceptions::BinaryInfixNotApplicable::display( std::ostream
& os
) const
679 if( expr1
!= 0 && expr2
!= 0 )
682 getLoc( ).copy( & os
);
683 os
<< " not defined for (" << valueType1
<< "," << valueType2
<< ") at " << expr1
->loc( ) << ", " << expr2
->loc( ) << "." << std::endl
;
687 os
<< "Operator " << operatorSymbol
<< " not defined for (" << valueType1
<< "," << valueType2
<< ")." << std::endl
;
692 Exceptions::LookupUnknown::LookupUnknown( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
, Type type
)
693 : Exceptions::StaticInconsistency( _loc
), id( _id
), type_( type
)
696 Exceptions::LookupUnknown::~LookupUnknown( )
700 Exceptions::LookupUnknown::display( std::ostream
& os
) const
705 os
<< "The variable " << id
<< " is unbound." << std::endl
;
708 os
<< "There is no state called " << id
<< " around." << std::endl
;
710 case DYNAMIC_VARIABLE
:
711 os
<< "There is no dynamic variable called " << id
<< " around." << std::endl
;
714 os
<< "There is no dynamic state called " << id
<< " around." << std::endl
;
717 os
<< "There is no type called " << id
<< " around." << std::endl
;
725 Exceptions::StateBeyondFunctionBoundary::StateBeyondFunctionBoundary( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
)
726 : Exceptions::StaticInconsistency( _loc
), id( _id
)
729 Exceptions::StateBeyondFunctionBoundary::~StateBeyondFunctionBoundary( )
733 Exceptions::StateBeyondFunctionBoundary::display( std::ostream
& os
) const
735 os
<< "The state " << id
<< " resides outside a function boundary." << std::endl
;
739 Exceptions::IntroducingExistingUnit::IntroducingExistingUnit( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
)
740 : Exceptions::StaticInconsistency( _loc
), id( _id
)
743 Exceptions::IntroducingExistingUnit::~IntroducingExistingUnit( )
747 Exceptions::IntroducingExistingUnit::display( std::ostream
& os
) const
749 os
<< "Inconsistent definition of the existing unit " << id
<< "." << std::endl
;
753 Exceptions::LookupUnknownUnit::LookupUnknownUnit( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
)
754 : Exceptions::StaticInconsistency( _loc
), id( _id
)
757 Exceptions::LookupUnknownUnit::~LookupUnknownUnit( )
761 Exceptions::LookupUnknownUnit::display( std::ostream
& os
) const
763 os
<< "The unit " << id
<< " is unbound" << std::endl
;
767 Exceptions::OutOfRange::OutOfRange( RefCountPtr
< const char > msg
)
768 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
771 Exceptions::OutOfRange::OutOfRange( const char * msg
)
772 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
775 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > msg
)
776 : Exceptions::CatchableError( _loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
779 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation
& _loc
, const char * msg
)
780 : Exceptions::CatchableError( _loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
783 Exceptions::OutOfRange::~OutOfRange( )
787 Exceptions::OutOfRange::display( std::ostream
& os
) const
789 os
<< "Out-of-range error: " << msg_
<< std::endl
;
792 RefCountPtr
< const Lang::Exception
>
793 Exceptions::OutOfRange::clone( const Kernel::ContRef
& cont
) const
795 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "out_of_range" ) );
796 std::ostringstream os
;
798 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
800 RefCountPtr
< const Lang::String
>( new Lang::String( "(core, generic)", true ) ),
804 this->exitCode( ) ) );
808 Exceptions::NonVoidStatement::NonVoidStatement( const Ast::SourceLocation
& loc
, RefCountPtr
< const Lang::Value
> val
)
809 : Exceptions::RuntimeError( loc
), val_( val
)
812 Exceptions::NonVoidStatement::~NonVoidStatement( )
816 Exceptions::NonVoidStatement::display( std::ostream
& os
) const
818 os
<< "No implicit ignore of non-void value (of type " << val_
->getTypeName( ) << ")" << std::endl
;
821 // Exceptions::RuntimeError::RuntimeError( )
822 // : loc_( "< unlocated runtime error >" )
825 Exceptions::RuntimeError::~RuntimeError( )
828 Exceptions::RuntimeError::RuntimeError( const Ast::SourceLocation
& loc
)
832 Exceptions::RuntimeError::RuntimeError( Ast::Expression
* expr
)
833 : loc_( expr
->loc( ) )
836 const Ast::SourceLocation
&
837 Exceptions::RuntimeError::getLoc( ) const
843 Exceptions::CatchableError::CatchableError( const Ast::SourceLocation
& loc
)
844 : Exceptions::RuntimeError( loc
)
847 Exceptions::CatchableError::CatchableError( Ast::Expression
* expr
)
848 : Exceptions::RuntimeError( expr
)
851 Exceptions::CatchableError::~CatchableError( )
855 Exceptions::UncaughtError::UncaughtError( const RefCountPtr
< const Lang::Exception
> & ball
)
856 : Exceptions::RuntimeError( ball
->loc( ) ), ball_( ball
)
859 Exceptions::UncaughtError::~UncaughtError( )
863 Exceptions::UncaughtError::display( std::ostream
& os
) const
865 os
<< "Uncaught error: " ;
870 Interaction::ExitCode
871 Exceptions::UncaughtError::exitCode( ) const
873 return ball_
->exitCode( );
877 Exceptions::UserError::UserError( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Value
> & details
, const RefCountPtr
< const char > & message
)
878 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), message_( message
)
881 Exceptions::UserError::~UserError( )
885 Exceptions::UserError::display( ostream
& os
) const
889 os
<< " error in " << source_
->val_
<< ": " << message_
<< std::endl
;
892 RefCountPtr
< const Lang::Exception
>
893 Exceptions::UserError::clone( const Kernel::ContRef
& cont
) const
895 std::ostringstream os
;
897 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
903 this->exitCode( ) ) );
907 Exceptions::UserOutOfRange::UserOutOfRange( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Integer
> & details
, const RefCountPtr
< const char > & message
)
908 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), message_( message
)
911 Exceptions::UserOutOfRange::~UserOutOfRange( )
915 Exceptions::UserOutOfRange::display( ostream
& os
) const
917 os
<< "In " << source_
->val_
<< ", argument " << details_
->val_
918 << ", out-of-range: " << message_
<< std::endl
;
921 RefCountPtr
< const Lang::Exception
>
922 Exceptions::UserOutOfRange::clone( const Kernel::ContRef
& cont
) const
924 std::ostringstream os
;
926 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
932 this->exitCode( ) ) );
936 Exceptions::UserTypeMismatch::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
)
937 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), expectedType_( expectedType
), valueType_( valueType
)
940 Exceptions::UserTypeMismatch::~UserTypeMismatch( )
944 Exceptions::UserTypeMismatch::display( ostream
& os
) const
946 os
<< "In " << source_
->val_
<< ", argument " << details_
->val_
947 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
950 RefCountPtr
< const Lang::Exception
>
951 Exceptions::UserTypeMismatch::clone( const Kernel::ContRef
& cont
) const
953 std::ostringstream os
;
955 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
961 this->exitCode( ) ) );
965 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
)
966 : Exceptions::RuntimeError( loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
969 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, const char * msg
)
970 : Exceptions::RuntimeError( loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
973 Exceptions::InternalError::InternalError( RefCountPtr
< const char > msg
)
974 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
977 Exceptions::InternalError::InternalError( const char * msg
)
978 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
981 Exceptions::InternalError::InternalError( const std::ostringstream
& msg
)
982 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( strdup( msg
.str( ).c_str( ) ) ), msgMem_( msg_
)
985 Exceptions::InternalError::~InternalError( )
989 Exceptions::InternalError::display( ostream
& os
) const
991 os
<< "Internal error: " << msg_
<< std::endl
;
995 Exceptions::ExternalError::ExternalError( RefCountPtr
< const char > msg
)
996 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
999 Exceptions::ExternalError::ExternalError( const char * msg
)
1000 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1003 Exceptions::ExternalError::~ExternalError( )
1007 Exceptions::ExternalError::display( ostream
& os
) const
1009 os
<< "External error: " << msg_
<< std::endl
;
1012 RefCountPtr
< const Lang::Exception
>
1013 Exceptions::ExternalError::clone( const Kernel::ContRef
& cont
) const
1015 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "external" ) );
1016 std::ostringstream os
;
1018 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1020 RefCountPtr
< const Lang::String
>( new Lang::String( "(external error)", true ) ),
1024 this->exitCode( ) ) );
1027 Exceptions::ExternalError
*
1028 Exceptions::ExternalError::cloneTyped( ) const
1030 return new Exceptions::ExternalError( msgMem_
);
1033 Exceptions::UserArityMismatch::UserArityMismatch( const Ast::SourceLocation _formalsLoc
, size_t _functionArity
, size_t _callArity
, Type type
)
1034 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), functionArity( _functionArity
), callArity( _callArity
), type_( type
)
1037 Exceptions::UserArityMismatch::~UserArityMismatch( )
1041 Exceptions::UserArityMismatch::display( std::ostream
& os
) const
1043 os
<< "Function with formals at " << formalsLoc
<< " expects " << functionArity
;
1047 os
<< " value arguments" ;
1050 os
<< " state arguments" ;
1055 os
<< ", not " << callArity
<< std::endl
;
1058 Exceptions::SinkRequired::SinkRequired( const Ast::SourceLocation formalsLoc
, size_t formalsArity
, size_t callArity
)
1059 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), formalsArity_( formalsArity
), callArity_( callArity
)
1062 Exceptions::SinkRequired::~SinkRequired( )
1066 Exceptions::SinkRequired::display( std::ostream
& os
) const
1068 os
<< "Formals at " << formalsLoc_
<< " contains no sink, so passing " << callArity_
<< " ordered arguments is " << callArity_
- formalsArity_
<< " too many." << std::endl
;
1072 Exceptions::NamedFormalMismatch::NamedFormalMismatch( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, Exceptions::NamedFormalMismatch::Type type
)
1073 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), name( _name
), type_( type
)
1076 Exceptions::NamedFormalMismatch::~NamedFormalMismatch( )
1080 Exceptions::NamedFormalMismatch::display( std::ostream
& os
) const
1082 os
<< "Function with formals at " << formalsLoc
<< " has no named ";
1094 os
<< " called " << name
<< "." << std::endl
;
1098 Exceptions::NamedFormalAlreadySpecified::NamedFormalAlreadySpecified( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, size_t _pos
, Exceptions::NamedFormalAlreadySpecified::Type type
)
1099 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), name( _name
), pos( _pos
), type_( type
)
1102 Exceptions::NamedFormalAlreadySpecified::~NamedFormalAlreadySpecified( )
1106 Exceptions::NamedFormalAlreadySpecified::display( std::ostream
& os
) const
1108 os
<< "The formal " ;
1120 os
<< " named " << name
<< ", defined at " << formalsLoc
<< " is already defined by order, at position " << pos
<< "." << std::endl
;
1123 Exceptions::MissingArguments::MissingArguments( const Ast::SourceLocation formalsLoc
, std::map
< size_t, RefCountPtr
< const char > > * missingVariables
, std::map
< size_t, RefCountPtr
< const char > > * missingStates
)
1124 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), missingVariables_( missingVariables
), missingStates_( missingStates
)
1127 Exceptions::MissingArguments::~MissingArguments( )
1131 Exceptions::MissingArguments::display( std::ostream
& os
) const
1133 os
<< "Among the formals at " << formalsLoc_
;
1134 if( missingVariables_
!= NullPtr
< typeof *missingVariables_
>( ) )
1136 os
<< ", the following variables are missing:" ;
1137 typedef typeof *missingVariables_ MapType
;
1138 for( MapType::const_iterator i
= missingVariables_
->begin( ); i
!= missingVariables_
->end( ); ++i
)
1140 if( i
!= missingVariables_
->begin( ) )
1144 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1147 if( missingStates_
!= NullPtr
< typeof *missingStates_
>( ) )
1150 if( missingVariables_
!= NullPtr
< typeof *missingVariables_
>( ) )
1154 os
<< "the following states are missing:" ;
1155 typedef typeof *missingStates_ MapType
;
1156 for( MapType::const_iterator i
= missingStates_
->begin( ); i
!= missingStates_
->end( ); ++i
)
1158 if( i
!= missingStates_
->begin( ) )
1162 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1165 os
<< "." << std::endl
;
1169 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * _title
, size_t _functionArity
, size_t _callArity
)
1170 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) ), functionArityLow( _functionArity
), functionArityHigh( _functionArity
), callArity( _callArity
)
1173 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
)
1174 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) ), functionArityLow( _functionArityLow
), functionArityHigh( _functionArityHigh
), callArity( _callArity
)
1177 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArity
, size_t _callArity
)
1178 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
), functionArityLow( _functionArity
), functionArityHigh( _functionArity
), callArity( _callArity
)
1181 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
)
1182 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
), functionArityLow( _functionArityLow
), functionArityHigh( _functionArityHigh
), callArity( _callArity
)
1185 Exceptions::CoreArityMismatch::~CoreArityMismatch( )
1189 Exceptions::CoreArityMismatch::display( std::ostream
& os
) const
1191 if( functionArityLow
== functionArityHigh
)
1193 os
<< "Core function " << title
<< " expects " << functionArityLow
<< " arguments, not " << callArity
<< std::endl
;
1197 os
<< "Core function " << title
<< " expects [" << functionArityLow
<< ", " << functionArityHigh
<< "] arguments, not " << callArity
<< std::endl
;
1202 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const char * _title
)
1203 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) )
1206 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const RefCountPtr
< const char > & _title
)
1207 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
)
1210 Exceptions::CoreNoNamedFormals::~CoreNoNamedFormals( )
1214 Exceptions::CoreNoNamedFormals::display( std::ostream
& os
) const
1216 os
<< "Core function " << title
<< " does not accept named arguments." << std::endl
;
1220 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1222 const Ast::SourceLocation
& argLoc
,
1223 RefCountPtr
< const char > valueType
,
1224 RefCountPtr
< const char > expectedType
)
1225 : Exceptions::RuntimeError( callLoc
),
1227 titleMem_( NullPtr
< const char >( ) ),
1229 valueType_( valueType
),
1230 expectedType_( expectedType
)
1233 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1234 RefCountPtr
< const char > title
,
1235 const Ast::SourceLocation
& argLoc
,
1236 RefCountPtr
< const char > valueType
,
1237 RefCountPtr
< const char > expectedType
)
1238 : Exceptions::RuntimeError( callLoc
),
1239 title_( title
.getPtr( ) ),
1242 valueType_( valueType
),
1243 expectedType_( expectedType
)
1246 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1248 Kernel::Arguments
& args
,
1250 RefCountPtr
< const char > expectedType
)
1251 : Exceptions::RuntimeError( callLoc
),
1253 titleMem_( NullPtr
< const char >( ) ),
1254 argLoc_( args
.getLoc( argNo
) ),
1255 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1256 expectedType_( expectedType
)
1259 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1260 RefCountPtr
< const char > title
,
1261 Kernel::Arguments
& args
,
1263 RefCountPtr
< const char > expectedType
)
1264 : Exceptions::RuntimeError( callLoc
),
1265 title_( title
.getPtr( ) ),
1267 argLoc_( args
.getLoc( argNo
) ),
1268 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1269 expectedType_( expectedType
)
1272 Exceptions::CoreTypeMismatch::~CoreTypeMismatch( )
1276 Exceptions::CoreTypeMismatch::display( std::ostream
& os
) const
1278 os
<< "Core function " << title_
<< ", argument ";
1279 // if( argName_ != 0 )
1281 // os << "\"" << argName_ << "\" " ;
1283 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1287 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1289 const Ast::SourceLocation
& argLoc
,
1290 RefCountPtr
< const char > valueType
,
1291 RefCountPtr
< const char > expectedType
)
1292 : Exceptions::RuntimeError( callLoc
),
1294 titleMem_( NullPtr
< const char >( ) ),
1296 valueType_( valueType
),
1297 expectedType_( expectedType
)
1300 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1301 RefCountPtr
< const char > title
,
1302 const Ast::SourceLocation
& argLoc
,
1303 RefCountPtr
< const char > valueType
,
1304 RefCountPtr
< const char > expectedType
)
1305 : Exceptions::RuntimeError( callLoc
),
1306 title_( title
.getPtr( ) ),
1309 valueType_( valueType
),
1310 expectedType_( expectedType
)
1313 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1315 Kernel::Arguments
& args
,
1317 RefCountPtr
< const char > expectedType
)
1318 : Exceptions::RuntimeError( callLoc
),
1320 titleMem_( NullPtr
< const char >( ) ),
1321 argLoc_( args
.getStateLoc( argNo
) ),
1322 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1323 expectedType_( expectedType
)
1326 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1327 RefCountPtr
< const char > title
,
1328 Kernel::Arguments
& args
,
1330 RefCountPtr
< const char > expectedType
)
1331 : Exceptions::RuntimeError( callLoc
),
1332 title_( title
.getPtr( ) ),
1334 argLoc_( args
.getStateLoc( argNo
) ),
1335 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1336 expectedType_( expectedType
)
1339 Exceptions::CoreStateTypeMismatch::~CoreStateTypeMismatch( )
1343 Exceptions::CoreStateTypeMismatch::display( std::ostream
& os
) const
1345 os
<< "Core function " << title_
<< ", state ";
1346 // if( argName_ != 0 )
1348 // os << "\"" << argName_ << "\" " ;
1350 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1354 Exceptions::CoreDynamicTypeMismatch::CoreDynamicTypeMismatch( const Ast::SourceLocation
& callLoc
,
1357 RefCountPtr
< const char > valueType
,
1358 RefCountPtr
< const char > expectedType
)
1359 : Exceptions::RuntimeError( callLoc
),
1361 titleMem_( NullPtr
< const char >( ) ),
1363 idMem_( NullPtr
< const char >( ) ),
1364 valueType_( valueType
),
1365 expectedType_( expectedType
)
1368 Exceptions::CoreDynamicTypeMismatch::~CoreDynamicTypeMismatch( )
1372 Exceptions::CoreDynamicTypeMismatch::display( std::ostream
& os
) const
1374 os
<< "Core function " << title_
<< " encountered a type mismatch in the dynamic variable @" << id_
1375 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1378 Exceptions::ContinuationTypeMismatch::ContinuationTypeMismatch( const Kernel::Continuation
* locationCont
,
1379 RefCountPtr
< const char > valueType
,
1380 RefCountPtr
< const char > expectedType
)
1381 : Exceptions::RuntimeError( locationCont
->traceLoc( ) ),
1382 valueType_( valueType
),
1383 expectedType_( expectedType
)
1386 Exceptions::ContinuationTypeMismatch::~ContinuationTypeMismatch( )
1390 Exceptions::ContinuationTypeMismatch::display( std::ostream
& os
) const
1392 os
<< "The continuation expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1396 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, RefCountPtr
< const char > msg
)
1397 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1400 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, const char * msg
)
1401 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1404 Exceptions::CoreOutOfRange::~CoreOutOfRange( )
1408 Exceptions::CoreOutOfRange::display( std::ostream
& os
) const
1410 os
<< "Core function " << title_
<< ": " ;
1411 os
<< "Argument at " << argLoc_
<< " is out of range; " << msg_
<< std::endl
;
1414 RefCountPtr
< const Lang::Exception
>
1415 Exceptions::CoreOutOfRange::clone( const Kernel::ContRef
& cont
) const
1417 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "out_of_range" ) );
1418 std::ostringstream os
;
1420 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1422 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1423 RefCountPtr
< const Lang::Integer
>( new Lang::Integer( argNo_
) ),
1426 this->exitCode( ) ) );
1429 Exceptions::CoreRequirement::CoreRequirement( RefCountPtr
< const char > msg
, const char * title
, const Ast::SourceLocation
& callLoc
)
1430 : Exceptions::CatchableError( callLoc
), title_( title
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1433 Exceptions::CoreRequirement::CoreRequirement( const char * msg
, const char * title
, const Ast::SourceLocation
& callLoc
)
1434 : Exceptions::CatchableError( callLoc
), title_( title
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1437 Exceptions::CoreRequirement::~CoreRequirement( )
1441 Exceptions::CoreRequirement::display( std::ostream
& os
) const
1443 os
<< "Core function " << title_
<< ": " << msg_
<< std::endl
;
1446 RefCountPtr
< const Lang::Exception
>
1447 Exceptions::CoreRequirement::clone( const Kernel::ContRef
& cont
) const
1449 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1450 std::ostringstream os
;
1452 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1454 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1458 this->exitCode( ) ) );
1462 Exceptions::BuildRequirement::BuildRequirement( const char * dependency
, const char * title
, const Ast::SourceLocation
& callLoc
)
1463 : Exceptions::CatchableError( callLoc
), title_( title
), dependency_( dependency
)
1466 Exceptions::BuildRequirement::~BuildRequirement( )
1470 Exceptions::BuildRequirement::display( std::ostream
& os
) const
1472 os
<< "Core function stub " << title_
<< ": Shapes was built without " << dependency_
<< ", so this function cannot be called." << std::endl
;
1475 RefCountPtr
< const Lang::Exception
>
1476 Exceptions::BuildRequirement::clone( const Kernel::ContRef
& cont
) const
1478 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1479 std::ostringstream os
;
1481 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1483 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1487 this->exitCode( ) ) );
1491 Exceptions::TeXLabelError::TeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1492 : Exceptions::RuntimeError( loc
), strLoc_( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1495 Exceptions::TeXLabelError::~TeXLabelError( )
1499 Exceptions::TeXLabelError::display( ostream
& os
) const
1503 os
<< "TeX error in " << region_
;
1507 os
<< "Error in TeX " << region_
;
1509 if( ! strLoc_
.isUnknown( ) )
1511 os
<< " at " << strLoc_
;
1524 if( details_
!= NullPtr
< const char >( ) )
1526 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1531 Exceptions::StaticTeXLabelError::StaticTeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1532 : Exceptions::StaticInconsistency( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1535 Exceptions::StaticTeXLabelError::~StaticTeXLabelError( )
1539 Exceptions::StaticTeXLabelError::display( ostream
& os
) const
1543 os
<< "TeX error in " << region_
;
1547 os
<< "Error in TeX " << region_
;
1560 if( details_
!= NullPtr
< const char >( ) )
1562 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1567 Exceptions::MultipleDynamicBind::MultipleDynamicBind( const char * _id
, const Ast::SourceLocation
& _loc
, const Ast::SourceLocation
& _prevLoc
)
1568 : Exceptions::RuntimeError( _loc
), id( _id
), prevLoc( _prevLoc
)
1571 Exceptions::MultipleDynamicBind::~MultipleDynamicBind( )
1575 Exceptions::MultipleDynamicBind::display( std::ostream
& os
) const
1577 os
<< "This dynamic binding of " << id
<< " is merged with the conflicting binding at " << prevLoc
<< "." << std::endl
;
1581 Exceptions::UndefinedEscapeContinuation::UndefinedEscapeContinuation( const char * _id
, const Ast::SourceLocation
& _loc
)
1582 : Exceptions::RuntimeError( _loc
), id( _id
)
1585 Exceptions::UndefinedEscapeContinuation::~UndefinedEscapeContinuation( )
1589 Exceptions::UndefinedEscapeContinuation::display( std::ostream
& os
) const
1591 os
<< "The escape continuation " << id
<< " was not defined in the dynamic context." << std::endl
;
1595 Exceptions::DeadStateAccess::DeadStateAccess( )
1596 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1599 Exceptions::DeadStateAccess::~DeadStateAccess( )
1603 Exceptions::DeadStateAccess::display( std::ostream
& os
) const
1605 os
<< "Accessing dead state." << std::endl
;
1609 Exceptions::UnFreezable::UnFreezable( )
1610 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1613 Exceptions::UnFreezable::~UnFreezable( )
1617 Exceptions::UnFreezable::display( std::ostream
& os
) const
1619 os
<< "The state cannot be frozen." << std::endl
;
1623 Exceptions::UnPeekable::UnPeekable( )
1624 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1627 Exceptions::UnPeekable::~UnPeekable( )
1631 Exceptions::UnPeekable::display( std::ostream
& os
) const
1633 os
<< "The state cannot be peeked. Consider freezing it." << std::endl
;
1637 Exceptions::UninitializedAccess::UninitializedAccess( )
1638 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1641 Exceptions::UninitializedAccess::~UninitializedAccess( )
1645 Exceptions::UninitializedAccess::display( std::ostream
& os
) const
1647 os
<< "The accessed variable or state has not been initialized yet." << std::endl
;
1651 Exceptions::DtMinError::DtMinError( double _dt
)
1652 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), dt( _dt
)
1655 Exceptions::DtMinError::~DtMinError( )
1659 Exceptions::DtMinError::display( std::ostream
& os
) const
1661 os
<< "Path segment too long in relation to arcdelta: dt = " << dt
<< " < " << Computation::the_dtMin
<< ". Either increase arcdelta, or inhibit this error." << std::endl
;
1664 RefCountPtr
< const Lang::Exception
>
1665 Exceptions::DtMinError::clone( const Kernel::ContRef
& cont
) const
1667 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "dtmin" ) );
1668 std::ostringstream os
;
1670 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1672 RefCountPtr
< const Lang::String
>( new Lang::String( "(core path computation)", true ) ),
1673 RefCountPtr
< const Lang::Float
>( new Lang::Float( dt
/ Computation::the_dtMin
) ),
1676 this->exitCode( ) ) );
1680 Exceptions::AffineTransformKillsPlane::AffineTransformKillsPlane( double sigma2
)
1681 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), sigma2_( sigma2
)
1684 Exceptions::AffineTransformKillsPlane::~AffineTransformKillsPlane( )
1688 Exceptions::AffineTransformKillsPlane::display( std::ostream
& os
) const
1690 os
<< "When transforming a plane normal, it was found that the affine transform is too singular, with a second largest singular value of " << sigma2_
<< "." << std::endl
;
1693 RefCountPtr
< const Lang::Exception
>
1694 Exceptions::AffineTransformKillsPlane::clone( const Kernel::ContRef
& cont
) const
1696 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "numeric" ) );
1697 std::ostringstream os
;
1699 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1701 RefCountPtr
< const Lang::String
>( new Lang::String( "(core float triple computation)", true ) ),
1705 this->exitCode( ) ) );
1708 Exceptions::MissingFontMetrics::MissingFontMetrics( RefCountPtr
< const char > fontname
, const std::list
< std::string
> * searchPath
)
1709 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), searchPath_( searchPath
)
1712 Exceptions::MissingFontMetrics::~MissingFontMetrics( )
1716 Exceptions::MissingFontMetrics::display( std::ostream
& os
) const
1718 os
<< "The font metrics for " << fontname_
<< ", named " << fontname_
<< ".afm, could not be found in {" ;
1719 typedef typeof *searchPath_ ListType
;
1720 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
1724 os
<< " }." << std::endl
;
1728 Exceptions::FontMetricsError::FontMetricsError( const RefCountPtr
< const char > & fontname
, const RefCountPtr
< const char > & message
)
1729 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), message_( message
)
1732 Exceptions::FontMetricsError::~FontMetricsError( )
1736 Exceptions::FontMetricsError::display( std::ostream
& os
) const
1738 os
<< "There was a problem with the font metrics for " << fontname_
<< ": " << message_
<< std::endl
;
1742 Exceptions::InsertingEmptyPage::InsertingEmptyPage( const Ast::SourceLocation
& loc
)
1743 : Exceptions::CatchableError( loc
)
1746 Exceptions::InsertingEmptyPage::~InsertingEmptyPage( )
1750 Exceptions::InsertingEmptyPage::display( std::ostream
& os
) const
1752 os
<< "Attempt to place empty page in catalog." << std::endl
;
1755 RefCountPtr
< const Lang::Exception
>
1756 Exceptions::InsertingEmptyPage::clone( const Kernel::ContRef
& cont
) const
1758 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1759 std::ostringstream os
;
1761 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1763 RefCountPtr
< const Lang::String
>( new Lang::String( "(core exception)", true ) ),
1767 this->exitCode( ) ) );
1771 Exceptions::UndefinedCrossRef::UndefinedCrossRef( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > ref
)
1772 : Exceptions::PostCondition( _loc
), ref_( ref
)
1775 Exceptions::UndefinedCrossRef::~UndefinedCrossRef( )
1779 Exceptions::UndefinedCrossRef::display( std::ostream
& os
) const
1781 os
<< "The cross reference \"" << ref_
<< "\" is not defined." << std::endl
;
1786 Exceptions::prefixEachLine( const std::string
& prefix
, std::istream
& src
, std::ostream
& dst
)
1789 for( std::getline( src
, line
); ! src
.eof( ); std::getline( src
, line
) )
1791 dst
<< prefix
<< line
<< std::endl
;
1796 Exceptions::prefixEachLine( const std::string
& prefix
, const RefCountPtr
< const char > & src
, std::ostream
& dst
)
1798 std::istringstream
is( src
.getPtr( ) );
1799 Exceptions::prefixEachLine( prefix
, is
, dst
);