mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed translationUnit exception handling to allow ParserErrors to propogate out.
This commit is contained in:
parent
cd01f65fe6
commit
15e615de07
2 changed files with 37 additions and 4 deletions
|
@ -1132,7 +1132,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
* @param e
|
||||
*/
|
||||
public void logException(String methodName, Exception e) {
|
||||
if( !(e instanceof EndOfFileException ))
|
||||
if( !(e instanceof EndOfFileException ) && e != null )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "Parser: Unexpected exception in "); //$NON-NLS-1$
|
||||
|
@ -1143,7 +1143,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
buffer.append( e.getMessage() );
|
||||
buffer.append( ". w/"); //$NON-NLS-1$
|
||||
buffer.append( scanner.toString() );
|
||||
log.traceLog( buffer.toString() );
|
||||
if( log.isTracing() )
|
||||
log.traceLog( buffer.toString() );
|
||||
log.errorLog( buffer.toString() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,16 +209,48 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
break;
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
logException( "translationUnit", e ); //$NON-NLS-1$
|
||||
failParse();
|
||||
}
|
||||
catch( ParseError perr )
|
||||
{
|
||||
throw perr;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if( e instanceof Exception )
|
||||
logException( "translationUnit", (Exception) e ); //$NON-NLS-1$
|
||||
logThrowable( "translationUnit", e ); //$NON-NLS-1$
|
||||
failParse();
|
||||
}
|
||||
}
|
||||
compilationUnit.exitScope( requestor, astFactory.getReferenceManager() );
|
||||
}
|
||||
/**
|
||||
* @param string
|
||||
* @param e
|
||||
*/
|
||||
private void logThrowable(String methodName, Throwable e) {
|
||||
if( e != null )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "Parser: Unexpected throwable in "); //$NON-NLS-1$
|
||||
buffer.append( methodName );
|
||||
buffer.append( ":"); //$NON-NLS-1$
|
||||
buffer.append( e.getClass().getName() );
|
||||
buffer.append( "::"); //$NON-NLS-1$
|
||||
buffer.append( e.getMessage() );
|
||||
buffer.append( ". w/"); //$NON-NLS-1$
|
||||
buffer.append( scanner.toString() );
|
||||
if( log.isTracing() )
|
||||
log.traceLog( buffer.toString() );
|
||||
log.errorLog( buffer.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This function is called whenever we encounter and error that we cannot backtrack out of and we
|
||||
* still wish to try and continue on with the parse to do a best-effort parse for our client.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue