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
, bool justAWarning
)
156 : Exceptions::StaticInconsistency( loc_
), msg_( msg
), justAWarning_( justAWarning
)
159 Exceptions::ParserError::~ParserError( )
163 Exceptions::ParserError::display( ostream
& os
) const
165 os
<< "Parser " << ( justAWarning_
? "warning" : "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
, bool justAWarning
)
483 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( msg
), msg_( msgMem_
.getPtr( ) ), justAWarning_( justAWarning
)
486 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const char * msg
, bool justAWarning
)
487 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( NullPtr
< const char >( ) ), msg_( msg
), justAWarning_( justAWarning
)
490 Exceptions::PDFVersionError::~PDFVersionError( )
494 Exceptions::PDFVersionError::display( std::ostream
& os
) const
496 os
<< SimplePDF::PDF_Version::toString( required_
) << " " << ( justAWarning_
? "warning" : "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::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, RefCountPtr
< const char > msg
, bool justAWarning
)
809 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), PostScript_name_( PostScript_name
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
812 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const char * msg
, bool justAWarning
)
813 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), PostScript_name_( PostScript_name
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
816 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > msg
, bool justAWarning
)
817 : Exceptions::CatchableError( _loc
), PostScript_name_( PostScript_name
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
820 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const Ast::SourceLocation
& _loc
, const char * msg
, bool justAWarning
)
821 : Exceptions::CatchableError( _loc
), PostScript_name_( PostScript_name
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
824 Exceptions::FontProblem::~FontProblem( )
828 Exceptions::FontProblem::display( std::ostream
& os
) const
830 os
<< "Font " << ( justAWarning_
? "warning" : "error" ) << " using " << PostScript_name_
->name( ) << ": " << msg_
<< std::endl
;
833 RefCountPtr
< const Lang::Exception
>
834 Exceptions::FontProblem::clone( const Kernel::ContRef
& cont
) const
836 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
837 std::ostringstream os
;
839 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
841 RefCountPtr
< const Lang::String
>( new Lang::String( "(font problem)", true ) ),
845 this->exitCode( ) ) );
849 Exceptions::NonVoidStatement::NonVoidStatement( const Ast::SourceLocation
& loc
, RefCountPtr
< const Lang::Value
> val
)
850 : Exceptions::RuntimeError( loc
), val_( val
)
853 Exceptions::NonVoidStatement::~NonVoidStatement( )
857 Exceptions::NonVoidStatement::display( std::ostream
& os
) const
859 os
<< "No implicit ignore of non-void value (of type " << val_
->getTypeName( ) << ")" << std::endl
;
862 // Exceptions::RuntimeError::RuntimeError( )
863 // : loc_( "< unlocated runtime error >" )
866 Exceptions::RuntimeError::~RuntimeError( )
869 Exceptions::RuntimeError::RuntimeError( const Ast::SourceLocation
& loc
)
873 Exceptions::RuntimeError::RuntimeError( Ast::Expression
* expr
)
874 : loc_( expr
->loc( ) )
877 const Ast::SourceLocation
&
878 Exceptions::RuntimeError::getLoc( ) const
884 Exceptions::CatchableError::CatchableError( const Ast::SourceLocation
& loc
)
885 : Exceptions::RuntimeError( loc
)
888 Exceptions::CatchableError::CatchableError( Ast::Expression
* expr
)
889 : Exceptions::RuntimeError( expr
)
892 Exceptions::CatchableError::~CatchableError( )
896 Exceptions::UncaughtError::UncaughtError( const RefCountPtr
< const Lang::Exception
> & ball
)
897 : Exceptions::RuntimeError( ball
->loc( ) ), ball_( ball
)
900 Exceptions::UncaughtError::~UncaughtError( )
904 Exceptions::UncaughtError::display( std::ostream
& os
) const
906 os
<< "Uncaught error: " ;
911 Interaction::ExitCode
912 Exceptions::UncaughtError::exitCode( ) const
914 return ball_
->exitCode( );
918 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
)
919 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), message_( message
)
922 Exceptions::UserError::~UserError( )
926 Exceptions::UserError::display( ostream
& os
) const
930 os
<< " error in " << source_
->val_
<< ": " << message_
<< std::endl
;
933 RefCountPtr
< const Lang::Exception
>
934 Exceptions::UserError::clone( const Kernel::ContRef
& cont
) const
936 std::ostringstream os
;
938 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
944 this->exitCode( ) ) );
948 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
)
949 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), message_( message
)
952 Exceptions::UserOutOfRange::~UserOutOfRange( )
956 Exceptions::UserOutOfRange::display( ostream
& os
) const
958 os
<< "In " << source_
->val_
<< ", argument " << details_
->val_
959 << ", out-of-range: " << message_
<< std::endl
;
962 RefCountPtr
< const Lang::Exception
>
963 Exceptions::UserOutOfRange::clone( const Kernel::ContRef
& cont
) const
965 std::ostringstream os
;
967 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
973 this->exitCode( ) ) );
977 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
)
978 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), expectedType_( expectedType
), valueType_( valueType
)
981 Exceptions::UserTypeMismatch::~UserTypeMismatch( )
985 Exceptions::UserTypeMismatch::display( ostream
& os
) const
987 os
<< "In " << source_
->val_
<< ", argument " << details_
->val_
988 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
991 RefCountPtr
< const Lang::Exception
>
992 Exceptions::UserTypeMismatch::clone( const Kernel::ContRef
& cont
) const
994 std::ostringstream os
;
996 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1002 this->exitCode( ) ) );
1006 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
, bool justAWarning
)
1007 : Exceptions::RuntimeError( loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
1010 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, const char * msg
, bool justAWarning
)
1011 : Exceptions::RuntimeError( loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
1014 Exceptions::InternalError::InternalError( RefCountPtr
< const char > msg
, bool justAWarning
)
1015 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
1018 Exceptions::InternalError::InternalError( const char * msg
, bool justAWarning
)
1019 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
1022 Exceptions::InternalError::InternalError( const std::ostringstream
& msg
, bool justAWarning
)
1023 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( strdup( msg
.str( ).c_str( ) ) ), msgMem_( msg_
), justAWarning_( justAWarning
)
1026 Exceptions::InternalError::~InternalError( )
1030 Exceptions::InternalError::display( ostream
& os
) const
1032 os
<< "Internal " << ( justAWarning_
? "warning" : "error" ) << ": " << msg_
<< std::endl
;
1036 Exceptions::ExternalError::ExternalError( RefCountPtr
< const char > msg
, bool justAWarning
)
1037 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
1040 Exceptions::ExternalError::ExternalError( const char * msg
, bool justAWarning
)
1041 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
1044 Exceptions::ExternalError::~ExternalError( )
1048 Exceptions::ExternalError::display( ostream
& os
) const
1050 os
<< "External " << ( justAWarning_
? "warning" : "error" ) << ": " << msg_
<< std::endl
;
1053 RefCountPtr
< const Lang::Exception
>
1054 Exceptions::ExternalError::clone( const Kernel::ContRef
& cont
) const
1056 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "external" ) );
1057 std::ostringstream os
;
1059 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1061 RefCountPtr
< const Lang::String
>( new Lang::String( "(external error)", true ) ),
1065 this->exitCode( ) ) );
1068 Exceptions::ExternalError
*
1069 Exceptions::ExternalError::cloneTyped( ) const
1071 return new Exceptions::ExternalError( msgMem_
);
1074 Exceptions::UserArityMismatch::UserArityMismatch( const Ast::SourceLocation _formalsLoc
, size_t _functionArity
, size_t _callArity
, Type type
)
1075 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), functionArity( _functionArity
), callArity( _callArity
), type_( type
)
1078 Exceptions::UserArityMismatch::~UserArityMismatch( )
1082 Exceptions::UserArityMismatch::display( std::ostream
& os
) const
1084 os
<< "Function with formals at " << formalsLoc
<< " expects " << functionArity
;
1088 os
<< " value arguments" ;
1091 os
<< " state arguments" ;
1096 os
<< ", not " << callArity
<< std::endl
;
1099 Exceptions::SinkRequired::SinkRequired( const Ast::SourceLocation formalsLoc
, size_t formalsArity
, size_t callArity
)
1100 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), formalsArity_( formalsArity
), callArity_( callArity
)
1103 Exceptions::SinkRequired::~SinkRequired( )
1107 Exceptions::SinkRequired::display( std::ostream
& os
) const
1109 os
<< "Formals at " << formalsLoc_
<< " contains no sink, so passing " << callArity_
<< " ordered arguments is " << callArity_
- formalsArity_
<< " too many." << std::endl
;
1113 Exceptions::NamedFormalMismatch::NamedFormalMismatch( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, Exceptions::NamedFormalMismatch::Type type
)
1114 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), name( _name
), type_( type
)
1117 Exceptions::NamedFormalMismatch::~NamedFormalMismatch( )
1121 Exceptions::NamedFormalMismatch::display( std::ostream
& os
) const
1123 os
<< "Function with formals at " << formalsLoc
<< " has no named ";
1135 os
<< " called " << name
<< "." << std::endl
;
1139 Exceptions::NamedFormalAlreadySpecified::NamedFormalAlreadySpecified( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, size_t _pos
, Exceptions::NamedFormalAlreadySpecified::Type type
)
1140 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), name( _name
), pos( _pos
), type_( type
)
1143 Exceptions::NamedFormalAlreadySpecified::~NamedFormalAlreadySpecified( )
1147 Exceptions::NamedFormalAlreadySpecified::display( std::ostream
& os
) const
1149 os
<< "The formal " ;
1161 os
<< " named " << name
<< ", defined at " << formalsLoc
<< " is already defined by order, at position " << pos
<< "." << std::endl
;
1164 Exceptions::MissingArguments::MissingArguments( const Ast::SourceLocation formalsLoc
, std::map
< size_t, RefCountPtr
< const char > > * missingVariables
, std::map
< size_t, RefCountPtr
< const char > > * missingStates
)
1165 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), missingVariables_( missingVariables
), missingStates_( missingStates
)
1168 Exceptions::MissingArguments::~MissingArguments( )
1172 Exceptions::MissingArguments::display( std::ostream
& os
) const
1174 os
<< "Among the formals at " << formalsLoc_
;
1175 if( missingVariables_
!= NullPtr
< typeof *missingVariables_
>( ) )
1177 os
<< ", the following variables are missing:" ;
1178 typedef typeof *missingVariables_ MapType
;
1179 for( MapType::const_iterator i
= missingVariables_
->begin( ); i
!= missingVariables_
->end( ); ++i
)
1181 if( i
!= missingVariables_
->begin( ) )
1185 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1188 if( missingStates_
!= NullPtr
< typeof *missingStates_
>( ) )
1191 if( missingVariables_
!= NullPtr
< typeof *missingVariables_
>( ) )
1195 os
<< "the following states are missing:" ;
1196 typedef typeof *missingStates_ MapType
;
1197 for( MapType::const_iterator i
= missingStates_
->begin( ); i
!= missingStates_
->end( ); ++i
)
1199 if( i
!= missingStates_
->begin( ) )
1203 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1206 os
<< "." << std::endl
;
1210 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * _title
, size_t _functionArity
, size_t _callArity
)
1211 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) ), functionArityLow( _functionArity
), functionArityHigh( _functionArity
), callArity( _callArity
)
1214 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
)
1215 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) ), functionArityLow( _functionArityLow
), functionArityHigh( _functionArityHigh
), callArity( _callArity
)
1218 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArity
, size_t _callArity
)
1219 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
), functionArityLow( _functionArity
), functionArityHigh( _functionArity
), callArity( _callArity
)
1222 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
)
1223 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
), functionArityLow( _functionArityLow
), functionArityHigh( _functionArityHigh
), callArity( _callArity
)
1226 Exceptions::CoreArityMismatch::~CoreArityMismatch( )
1230 Exceptions::CoreArityMismatch::display( std::ostream
& os
) const
1232 if( functionArityLow
== functionArityHigh
)
1234 os
<< "Core function " << title
<< " expects " << functionArityLow
<< " arguments, not " << callArity
<< std::endl
;
1238 os
<< "Core function " << title
<< " expects [" << functionArityLow
<< ", " << functionArityHigh
<< "] arguments, not " << callArity
<< std::endl
;
1243 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const char * _title
)
1244 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) )
1247 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const RefCountPtr
< const char > & _title
)
1248 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
)
1251 Exceptions::CoreNoNamedFormals::~CoreNoNamedFormals( )
1255 Exceptions::CoreNoNamedFormals::display( std::ostream
& os
) const
1257 os
<< "Core function " << title
<< " does not accept named arguments." << std::endl
;
1261 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1263 const Ast::SourceLocation
& argLoc
,
1264 RefCountPtr
< const char > valueType
,
1265 RefCountPtr
< const char > expectedType
)
1266 : Exceptions::RuntimeError( callLoc
),
1268 titleMem_( NullPtr
< const char >( ) ),
1270 valueType_( valueType
),
1271 expectedType_( expectedType
)
1274 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1275 RefCountPtr
< const char > title
,
1276 const Ast::SourceLocation
& argLoc
,
1277 RefCountPtr
< const char > valueType
,
1278 RefCountPtr
< const char > expectedType
)
1279 : Exceptions::RuntimeError( callLoc
),
1280 title_( title
.getPtr( ) ),
1283 valueType_( valueType
),
1284 expectedType_( expectedType
)
1287 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1289 Kernel::Arguments
& args
,
1291 RefCountPtr
< const char > expectedType
)
1292 : Exceptions::RuntimeError( callLoc
),
1294 titleMem_( NullPtr
< const char >( ) ),
1295 argLoc_( args
.getLoc( argNo
) ),
1296 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1297 expectedType_( expectedType
)
1300 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1301 RefCountPtr
< const char > title
,
1302 Kernel::Arguments
& args
,
1304 RefCountPtr
< const char > expectedType
)
1305 : Exceptions::RuntimeError( callLoc
),
1306 title_( title
.getPtr( ) ),
1308 argLoc_( args
.getLoc( argNo
) ),
1309 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1310 expectedType_( expectedType
)
1313 Exceptions::CoreTypeMismatch::~CoreTypeMismatch( )
1317 Exceptions::CoreTypeMismatch::display( std::ostream
& os
) const
1319 os
<< "Core function " << title_
<< ", argument ";
1320 // if( argName_ != 0 )
1322 // os << "\"" << argName_ << "\" " ;
1324 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1328 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1330 const Ast::SourceLocation
& argLoc
,
1331 RefCountPtr
< const char > valueType
,
1332 RefCountPtr
< const char > expectedType
)
1333 : Exceptions::RuntimeError( callLoc
),
1335 titleMem_( NullPtr
< const char >( ) ),
1337 valueType_( valueType
),
1338 expectedType_( expectedType
)
1341 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1342 RefCountPtr
< const char > title
,
1343 const Ast::SourceLocation
& argLoc
,
1344 RefCountPtr
< const char > valueType
,
1345 RefCountPtr
< const char > expectedType
)
1346 : Exceptions::RuntimeError( callLoc
),
1347 title_( title
.getPtr( ) ),
1350 valueType_( valueType
),
1351 expectedType_( expectedType
)
1354 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1356 Kernel::Arguments
& args
,
1358 RefCountPtr
< const char > expectedType
)
1359 : Exceptions::RuntimeError( callLoc
),
1361 titleMem_( NullPtr
< const char >( ) ),
1362 argLoc_( args
.getStateLoc( argNo
) ),
1363 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1364 expectedType_( expectedType
)
1367 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1368 RefCountPtr
< const char > title
,
1369 Kernel::Arguments
& args
,
1371 RefCountPtr
< const char > expectedType
)
1372 : Exceptions::RuntimeError( callLoc
),
1373 title_( title
.getPtr( ) ),
1375 argLoc_( args
.getStateLoc( argNo
) ),
1376 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1377 expectedType_( expectedType
)
1380 Exceptions::CoreStateTypeMismatch::~CoreStateTypeMismatch( )
1384 Exceptions::CoreStateTypeMismatch::display( std::ostream
& os
) const
1386 os
<< "Core function " << title_
<< ", state ";
1387 // if( argName_ != 0 )
1389 // os << "\"" << argName_ << "\" " ;
1391 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1395 Exceptions::CoreDynamicTypeMismatch::CoreDynamicTypeMismatch( const Ast::SourceLocation
& callLoc
,
1398 RefCountPtr
< const char > valueType
,
1399 RefCountPtr
< const char > expectedType
)
1400 : Exceptions::RuntimeError( callLoc
),
1402 titleMem_( NullPtr
< const char >( ) ),
1404 idMem_( NullPtr
< const char >( ) ),
1405 valueType_( valueType
),
1406 expectedType_( expectedType
)
1409 Exceptions::CoreDynamicTypeMismatch::~CoreDynamicTypeMismatch( )
1413 Exceptions::CoreDynamicTypeMismatch::display( std::ostream
& os
) const
1415 os
<< "Core function " << title_
<< " encountered a type mismatch in the dynamic variable @" << id_
1416 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1419 Exceptions::ContinuationTypeMismatch::ContinuationTypeMismatch( const Kernel::Continuation
* locationCont
,
1420 RefCountPtr
< const char > valueType
,
1421 RefCountPtr
< const char > expectedType
)
1422 : Exceptions::RuntimeError( locationCont
->traceLoc( ) ),
1423 valueType_( valueType
),
1424 expectedType_( expectedType
)
1427 Exceptions::ContinuationTypeMismatch::~ContinuationTypeMismatch( )
1431 Exceptions::ContinuationTypeMismatch::display( std::ostream
& os
) const
1433 os
<< "The continuation expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1437 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, RefCountPtr
< const char > msg
)
1438 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1441 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, const char * msg
)
1442 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1445 Exceptions::CoreOutOfRange::~CoreOutOfRange( )
1449 Exceptions::CoreOutOfRange::display( std::ostream
& os
) const
1451 os
<< "Core function " << title_
<< ": " ;
1452 os
<< "Argument at " << argLoc_
<< " is out of range; " << msg_
<< std::endl
;
1455 RefCountPtr
< const Lang::Exception
>
1456 Exceptions::CoreOutOfRange::clone( const Kernel::ContRef
& cont
) const
1458 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "out_of_range" ) );
1459 std::ostringstream os
;
1461 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1463 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1464 RefCountPtr
< const Lang::Integer
>( new Lang::Integer( argNo_
) ),
1467 this->exitCode( ) ) );
1470 Exceptions::CoreRequirement::CoreRequirement( RefCountPtr
< const char > msg
, const char * title
, const Ast::SourceLocation
& callLoc
)
1471 : Exceptions::CatchableError( callLoc
), title_( title
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1474 Exceptions::CoreRequirement::CoreRequirement( const char * msg
, const char * title
, const Ast::SourceLocation
& callLoc
)
1475 : Exceptions::CatchableError( callLoc
), title_( title
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1478 Exceptions::CoreRequirement::~CoreRequirement( )
1482 Exceptions::CoreRequirement::display( std::ostream
& os
) const
1484 os
<< "Core function " << title_
<< ": " << msg_
<< std::endl
;
1487 RefCountPtr
< const Lang::Exception
>
1488 Exceptions::CoreRequirement::clone( const Kernel::ContRef
& cont
) const
1490 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1491 std::ostringstream os
;
1493 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1495 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1499 this->exitCode( ) ) );
1503 Exceptions::BuildRequirement::BuildRequirement( const char * dependency
, const char * title
, const Ast::SourceLocation
& callLoc
)
1504 : Exceptions::CatchableError( callLoc
), title_( title
), dependency_( dependency
)
1507 Exceptions::BuildRequirement::~BuildRequirement( )
1511 Exceptions::BuildRequirement::display( std::ostream
& os
) const
1513 os
<< "Core function stub " << title_
<< ": Shapes was built without " << dependency_
<< ", so this function cannot be called." << std::endl
;
1516 RefCountPtr
< const Lang::Exception
>
1517 Exceptions::BuildRequirement::clone( const Kernel::ContRef
& cont
) const
1519 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1520 std::ostringstream os
;
1522 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1524 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1528 this->exitCode( ) ) );
1532 Exceptions::TeXLabelError::TeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1533 : Exceptions::RuntimeError( loc
), strLoc_( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1536 Exceptions::TeXLabelError::~TeXLabelError( )
1540 Exceptions::TeXLabelError::display( ostream
& os
) const
1544 os
<< "TeX error in " << region_
;
1548 os
<< "Error in TeX " << region_
;
1550 if( ! strLoc_
.isUnknown( ) )
1552 os
<< " at " << strLoc_
;
1565 if( details_
!= NullPtr
< const char >( ) )
1567 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1572 Exceptions::StaticTeXLabelError::StaticTeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1573 : Exceptions::StaticInconsistency( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1576 Exceptions::StaticTeXLabelError::~StaticTeXLabelError( )
1580 Exceptions::StaticTeXLabelError::display( ostream
& os
) const
1584 os
<< "TeX error in " << region_
;
1588 os
<< "Error in TeX " << region_
;
1601 if( details_
!= NullPtr
< const char >( ) )
1603 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1608 Exceptions::MultipleDynamicBind::MultipleDynamicBind( const char * _id
, const Ast::SourceLocation
& _loc
, const Ast::SourceLocation
& _prevLoc
)
1609 : Exceptions::RuntimeError( _loc
), id( _id
), prevLoc( _prevLoc
)
1612 Exceptions::MultipleDynamicBind::~MultipleDynamicBind( )
1616 Exceptions::MultipleDynamicBind::display( std::ostream
& os
) const
1618 os
<< "This dynamic binding of " << id
<< " is merged with the conflicting binding at " << prevLoc
<< "." << std::endl
;
1622 Exceptions::UndefinedEscapeContinuation::UndefinedEscapeContinuation( const char * _id
, const Ast::SourceLocation
& _loc
)
1623 : Exceptions::RuntimeError( _loc
), id( _id
)
1626 Exceptions::UndefinedEscapeContinuation::~UndefinedEscapeContinuation( )
1630 Exceptions::UndefinedEscapeContinuation::display( std::ostream
& os
) const
1632 os
<< "The escape continuation " << id
<< " was not defined in the dynamic context." << std::endl
;
1636 Exceptions::DeadStateAccess::DeadStateAccess( )
1637 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1640 Exceptions::DeadStateAccess::~DeadStateAccess( )
1644 Exceptions::DeadStateAccess::display( std::ostream
& os
) const
1646 os
<< "Accessing dead state." << std::endl
;
1650 Exceptions::UnFreezable::UnFreezable( )
1651 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1654 Exceptions::UnFreezable::~UnFreezable( )
1658 Exceptions::UnFreezable::display( std::ostream
& os
) const
1660 os
<< "The state cannot be frozen." << std::endl
;
1664 Exceptions::UnPeekable::UnPeekable( )
1665 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1668 Exceptions::UnPeekable::~UnPeekable( )
1672 Exceptions::UnPeekable::display( std::ostream
& os
) const
1674 os
<< "The state cannot be peeked. Consider freezing it." << std::endl
;
1678 Exceptions::UninitializedAccess::UninitializedAccess( )
1679 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1682 Exceptions::UninitializedAccess::~UninitializedAccess( )
1686 Exceptions::UninitializedAccess::display( std::ostream
& os
) const
1688 os
<< "The accessed variable or state has not been initialized yet." << std::endl
;
1692 Exceptions::DtMinError::DtMinError( double _dt
)
1693 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), dt( _dt
)
1696 Exceptions::DtMinError::~DtMinError( )
1700 Exceptions::DtMinError::display( std::ostream
& os
) const
1702 os
<< "Path segment too long in relation to arcdelta: dt = " << dt
<< " < " << Computation::the_dtMin
<< ". Either increase arcdelta, or inhibit this error." << std::endl
;
1705 RefCountPtr
< const Lang::Exception
>
1706 Exceptions::DtMinError::clone( const Kernel::ContRef
& cont
) const
1708 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "dtmin" ) );
1709 std::ostringstream os
;
1711 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1713 RefCountPtr
< const Lang::String
>( new Lang::String( "(core path computation)", true ) ),
1714 RefCountPtr
< const Lang::Float
>( new Lang::Float( dt
/ Computation::the_dtMin
) ),
1717 this->exitCode( ) ) );
1721 Exceptions::AffineTransformKillsPlane::AffineTransformKillsPlane( double sigma2
)
1722 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), sigma2_( sigma2
)
1725 Exceptions::AffineTransformKillsPlane::~AffineTransformKillsPlane( )
1729 Exceptions::AffineTransformKillsPlane::display( std::ostream
& os
) const
1731 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
;
1734 RefCountPtr
< const Lang::Exception
>
1735 Exceptions::AffineTransformKillsPlane::clone( const Kernel::ContRef
& cont
) const
1737 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "numeric" ) );
1738 std::ostringstream os
;
1740 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1742 RefCountPtr
< const Lang::String
>( new Lang::String( "(core float triple computation)", true ) ),
1746 this->exitCode( ) ) );
1749 Exceptions::MissingFontMetrics::MissingFontMetrics( RefCountPtr
< const char > fontname
, const std::list
< std::string
> * searchPath
)
1750 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), searchPath_( searchPath
)
1753 Exceptions::MissingFontMetrics::~MissingFontMetrics( )
1757 Exceptions::MissingFontMetrics::display( std::ostream
& os
) const
1759 os
<< "The font metrics for " << fontname_
<< ", named " << fontname_
<< ".afm, could not be found in {" ;
1760 typedef typeof *searchPath_ ListType
;
1761 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
1765 os
<< " }." << std::endl
;
1769 Exceptions::FontMetricsError::FontMetricsError( const RefCountPtr
< const char > & fontname
, const RefCountPtr
< const char > & message
)
1770 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), message_( message
)
1773 Exceptions::FontMetricsError::~FontMetricsError( )
1777 Exceptions::FontMetricsError::display( std::ostream
& os
) const
1779 os
<< "There was a problem with the font metrics for " << fontname_
<< ": " << message_
<< std::endl
;
1783 Exceptions::InsertingEmptyPage::InsertingEmptyPage( const Ast::SourceLocation
& loc
)
1784 : Exceptions::CatchableError( loc
)
1787 Exceptions::InsertingEmptyPage::~InsertingEmptyPage( )
1791 Exceptions::InsertingEmptyPage::display( std::ostream
& os
) const
1793 os
<< "Attempt to place empty page in catalog." << std::endl
;
1796 RefCountPtr
< const Lang::Exception
>
1797 Exceptions::InsertingEmptyPage::clone( const Kernel::ContRef
& cont
) const
1799 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1800 std::ostringstream os
;
1802 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1804 RefCountPtr
< const Lang::String
>( new Lang::String( "(core exception)", true ) ),
1808 this->exitCode( ) ) );
1812 Exceptions::UndefinedCrossRef::UndefinedCrossRef( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > ref
)
1813 : Exceptions::PostCondition( _loc
), ref_( ref
)
1816 Exceptions::UndefinedCrossRef::~UndefinedCrossRef( )
1820 Exceptions::UndefinedCrossRef::display( std::ostream
& os
) const
1822 os
<< "The cross reference \"" << ref_
<< "\" is not defined." << std::endl
;
1827 Exceptions::prefixEachLine( const std::string
& prefix
, std::istream
& src
, std::ostream
& dst
)
1830 for( std::getline( src
, line
); ! src
.eof( ); std::getline( src
, line
) )
1832 dst
<< prefix
<< line
<< std::endl
;
1837 Exceptions::prefixEachLine( const std::string
& prefix
, const RefCountPtr
< const char > & src
, std::ostream
& dst
)
1839 std::istringstream
is( src
.getPtr( ) );
1840 Exceptions::prefixEachLine( prefix
, is
, dst
);