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
|
* @param e
|
||||||
*/
|
*/
|
||||||
public void logException(String methodName, Exception e) {
|
public void logException(String methodName, Exception e) {
|
||||||
if( !(e instanceof EndOfFileException ))
|
if( !(e instanceof EndOfFileException ) && e != null )
|
||||||
{
|
{
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append( "Parser: Unexpected exception in "); //$NON-NLS-1$
|
buffer.append( "Parser: Unexpected exception in "); //$NON-NLS-1$
|
||||||
|
@ -1143,6 +1143,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
buffer.append( e.getMessage() );
|
buffer.append( e.getMessage() );
|
||||||
buffer.append( ". w/"); //$NON-NLS-1$
|
buffer.append( ". w/"); //$NON-NLS-1$
|
||||||
buffer.append( scanner.toString() );
|
buffer.append( scanner.toString() );
|
||||||
|
if( log.isTracing() )
|
||||||
log.traceLog( buffer.toString() );
|
log.traceLog( buffer.toString() );
|
||||||
log.errorLog( buffer.toString() );
|
log.errorLog( buffer.toString() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,15 +209,47 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
logException( "translationUnit", e ); //$NON-NLS-1$
|
||||||
|
failParse();
|
||||||
|
}
|
||||||
|
catch( ParseError perr )
|
||||||
|
{
|
||||||
|
throw perr;
|
||||||
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
if( e instanceof Exception )
|
logThrowable( "translationUnit", e ); //$NON-NLS-1$
|
||||||
logException( "translationUnit", (Exception) e ); //$NON-NLS-1$
|
|
||||||
failParse();
|
failParse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compilationUnit.exitScope( requestor, astFactory.getReferenceManager() );
|
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
|
* 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.
|
* 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