o improved exceptions handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@19954 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mguesdon 2004-09-01 14:28:01 +00:00
parent a8f85a3ec1
commit 8f4fe72e92

View file

@ -61,15 +61,27 @@ RCS_ID("$Id$")
{
GSWHTMLRawParser* htmlRawParser = [GSWHTMLRawParser parserWithDelegate:self
htmlString:_string];
[htmlRawParser parseHTML];
NSDebugMLog(@"_currentElement=%@",_currentElement);
NS_DURING
{
[htmlRawParser parseHTML];
}
NS_HANDLER
{
[[[localException class]
exceptionWithName:[localException name]
reason:[NSString stringWithFormat:@"In template named %@: %@",
_templateName,[localException reason]]
userInfo:[localException userInfo]]raise];
}
NS_ENDHANDLER;
if ([_currentElement parentElement])
{
NSDebugMLog(@"_currentElement=%@",_currentElement);
[NSException raise:NSInvalidArgumentException
format:@"Missing dynamic tag end after reaching end of template. Tag name is '%@'. templateInfo: %@",
[_currentElement name],[_currentElement templateInfo]];
format:@"In template named %@: Missing dynamic tag end after reaching end of template. Tag name is '%@'. templateInfo: %@",
_templateName,[_currentElement name],[_currentElement templateInfo]];
}
else
template=[_currentElement template];
@ -91,6 +103,17 @@ RCS_ID("$Id$")
_currentElement = [GSWTemporaryElement temporaryElement];
template=[self parseHTML];
// If we've found error raise exception
NSDebugMLog(@"_errorMessages=%@",_errorMessages);
if ([[self errorMessages]count]>0)
{
NSDebugMLog(@"declarationsFilePath=%@",_declarationsFilePath);
NSDebugMLog(@"errorMessages=%@",[self errorMessages]);
ExceptionRaise(@"GSWHTMLTemplateParser",@"%@\nDefinitionFiles: %@",
[self errorMessagesAsText],
_processedDeclarationsFilePaths);
};
LOGObjectFnStop();
return template;
@ -174,14 +197,37 @@ Creates a dynamic element from current temporary element element
}
else
{
GSWElement* element = nil;
element = [_currentElement dynamicElementWithDeclarations:_declarations
languages:_languages];
NSDebugMLog(@"element=%@",element);
NS_DURING
{
GSWElement* element = nil;
element = [_currentElement dynamicElementWithDeclarations:_declarations
languages:_languages];
NSDebugMLog(@"element=%@",element);
NSAssert2(element,@"No element for %@ with declarations %@",_currentElement,_declarations);
NSAssert2(element,@"No element for %@ with declarations %@",_currentElement,_declarations);
[parent addChildElement:element];
}
NS_HANDLER
{
NSDebugMLog(@"Exception: %@",localException);
if ([localException isKindOfClass:[GSWDeclarationFormatException class]]
&& [(GSWDeclarationFormatException*)localException canDelay])
{
[self addErrorMessageFormat:@"In template named %@: %@",
_templateName,[localException description]];
}
else
{
[[[localException class]
exceptionWithName:[localException name]
reason:[NSString stringWithFormat:@"In template named %@: %@",
_templateName,[localException reason]]
userInfo:[localException userInfo]]raise];
};
}
NS_ENDHANDLER;
[parent addChildElement:element];
_currentElement = parent;
NSDebugMLog(@"New (Parent) _currentElement=%@",_currentElement);