Transform inline error text to ResourceString

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1354 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2010-10-16 18:22:28 +00:00
parent efe4017021
commit 3524335cab
2 changed files with 64 additions and 39 deletions

View File

@ -217,10 +217,10 @@ class function TAbstractTypeParser.ExtractEmbeddedTypeFromElement(
);
locCrs.Reset();
if not locCrs.MoveNext() then
raise EXsdParserException.Create('Unable to find the <name> tag in the type/element node attributes.');
raise EXsdParserException.Create(SERR_UnableToFindNameTagInNode);
Result := (locCrs.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
if IsStrEmpty(Result) then begin
raise EXsdParserException.Create('Invalid type/element name( the name is empty ).');
raise EXsdParserException.Create(SERR_InvalidTypeName);
end;
end;
@ -256,7 +256,7 @@ var
typNode : TDOMNode;
begin
if not AEltNode.HasChildNodes() then begin;
raise EXsdParserException.Create('Invalid type definition, this element must have children.');
raise EXsdParserException.Create(SERR_InvalidTypeDef_NoChild);
end;
typName := ATypeName;
if IsStrEmpty(typName) then begin
@ -264,7 +264,7 @@ begin
end;
prsClss := FindParser(typNode);
if ( prsClss = nil ) then begin;
raise EXsdInvalidTypeDefinitionException.CreateFmt('This type style is not supported : "%s".',[typName]);
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_TypeStyleNotSupported,[typName]);
end;
prs := prsClss.Create(AOwner,typNode,typName,True);
try
@ -599,7 +599,7 @@ var
nd : TDOMNode;
begin
if not FDerivationNode.HasChildNodes then begin
raise EXsdInvalidTypeDefinitionException.CreateFmt('Invalid type definition, attributes not found : "%s".',[FTypeName]);
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidTypeDef_AttributeNotFound,[FTypeName]);
end;
crs := CreateCursorOn(
CreateChildrenCursor(FDerivationNode,cetRttiNode),
@ -632,7 +632,7 @@ begin
FreeAndNil(ls);
end;
if not ok then begin
raise EXsdInvalidTypeDefinitionException.CreateFmt('Invalid type definition, unable to find the "%s" attribute : "%s".',[s_arrayType,FTypeName]);
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidTypeDef_NamedAttributeNotFound,[s_arrayType,FTypeName]);
end;
s := ExtractNameFromQName((locCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject.NodeValue);
i := Pos('[',s);
@ -647,7 +647,7 @@ begin
Self.Module.InterfaceSection.Types.Add(locSym);
end;
if not locSym.InheritsFrom(TPasType) then
raise EXsdInvalidTypeDefinitionException.CreateFmt('Invalid array type definition, invalid item type definition : "%s".',[FTypeName]);
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_InvalidArrayItemType,[FTypeName]);
Result := FSymbols.CreateArray(AInternalName,locSym as TPasType,s_item,s_item,asScoped);
if AHasInternalName then
FSymbols.RegisterExternalAlias(Result,ATypeName);
@ -684,11 +684,11 @@ begin
);
locCrs.Reset();
if not locCrs.MoveNext() then
raise EXsdParserException.Create('Unable to find the <name> tag in the type node attributes.');
raise EXsdParserException.Create(SERR_UnableToFindNameTagInNode);
FTypeName := (locCrs.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
end;
if IsStrEmpty(FTypeName) then
raise EXsdParserException.Create('Invalid type name( the name is empty ).');
raise EXsdParserException.Create(SERR_InvalidTypeName);
end;
procedure TComplexTypeParser.ExtractContentType();
@ -764,7 +764,7 @@ begin
);
locCrs.Reset();
if not locCrs.MoveNext() then
raise EXsdParserException.CreateFmt('Invalid extention/restriction of type "%s" : "base" attribute not found.',[FTypeName]);
raise EXsdParserException.CreateFmt(SERR_InvalidTypeDef_BaseAttributeNotFound,[FTypeName]);
ExplodeQName((locCrs.GetCurrent() as TDOMNodeRttiExposer).NodeValue,locBaseTypeLocalName,locBaseTypeLocalSpace);
locSymbol := FindElementNS(locBaseTypeLocalSpace,locBaseTypeLocalName,nvtShortSynonym);
if Assigned(locSymbol) then begin
@ -781,7 +781,7 @@ begin
FBaseType := TPasNativeClassType(FBaseType).ExtendableType;
end;
end else begin
raise EXsdParserException.CreateFmt('"%s" was expected to be a type definition.',[locSymbol.Name]);
raise EXsdParserException.CreateFmt(SERR_ExpectedTypeDefinition,[locSymbol.Name]);
end;
end else begin
if ( FDerivationMode = dmRestriction ) and
@ -845,7 +845,7 @@ var
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_ref)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if not locPartCursor.MoveNext() then begin
raise EXsdParserException.Create('Invalid <element> definition : missing "name" or "ref" attribute.');
raise EXsdParserException.Create(SERR_InvalidElementDef_MissingNameOrRef);
end;
locIsRefElement := True;
end;
@ -854,7 +854,7 @@ var
locName := ExtractNameFromQName(locName);
end;
if IsStrEmpty(locName) then
raise EXsdParserException.Create('Invalid <element> definition : empty "name".');
raise EXsdParserException.Create(SERR_InvalidElementDef_EmptyName);
if locIsRefElement then begin
locTypeName := locName;
end else begin
@ -867,7 +867,7 @@ var
locTypeName := Format('%s_%s_Type',[FTypeName,locName]);
locType := TAbstractTypeParser.ExtractEmbeddedTypeFromElement(Context,AElement,FSymbols,locTypeName);
if ( locType = nil ) then begin
raise EXsdInvalidElementDefinitionException.CreateFmt('Invalid <element> definition : unable to determine the type.'#13'Type name : "%s"; Element name :"%s".',[FTypeName,locName]);
raise EXsdInvalidElementDefinitionException.CreateFmt(SERR_InvalidElementDef_Type,[FTypeName,locName]);
end;
Self.Module.InterfaceSection.Declarations.Add(locType);
Self.Module.InterfaceSection.Types.Add(locType);
@ -877,7 +877,7 @@ var
end;
end;
if IsStrEmpty(locTypeName) then
raise EXsdInvalidElementDefinitionException.Create('Invalid <element> definition : empty "type".');
raise EXsdInvalidElementDefinitionException.Create(SERR_InvalidElementDef_EmptyType);
locType := FindElementWithHint(locTypeName,locTypeHint,ssGlobal);
if Assigned(locType) then begin
if locIsRefElement then begin
@ -927,13 +927,13 @@ var
if locPartCursor.MoveNext() then begin
locStrBuffer := ExtractNameFromQName((locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue);
if IsStrEmpty(locStrBuffer) then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : empty "use".',[s_attribute]);
raise EXsdInvalidDefinitionException.Create(SERR_InvalidAttributeDef_EmptyUse);
case AnsiIndexText(locStrBuffer,[s_required,s_optional,s_prohibited]) of
0 : locMinOccur := 1;
1 : locMinOccur := 0;
2 : locMinOccur := -1;
else
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : invalid "use" value "%s".',[s_attribute,locStrBuffer]);
raise EXsdInvalidDefinitionException.CreateFmt(SERR_InvalidAttributeDef_InvalidUse,[locStrBuffer]);
end;
end else begin
locMinOccur := 0;
@ -944,9 +944,9 @@ var
locPartCursor.Reset();
if locPartCursor.MoveNext() then begin
if not TryStrToInt((locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue,locMinOccur) then
raise EXsdParserException.CreateFmt('Invalid "minOccurs" value : "%s.%s".',[FTypeName,locName]);
raise EXsdParserException.CreateFmt(SERR_InvalidMinOccursValue,[FTypeName,locName]);
if ( locMinOccur < 0 ) then
raise EXsdParserException.CreateFmt('Invalid "minOccurs" value : "%s.%s".',[FTypeName,locName]);
raise EXsdParserException.CreateFmt(SERR_InvalidMinOccursValue,[FTypeName,locName]);
end;
end;
locProp.ReadAccessorName := 'F' + locProp.Name;
@ -969,9 +969,9 @@ var
locMaxOccurUnbounded := True;
end else begin
if not TryStrToInt(locStrBuffer,locMaxOccur) then
raise EXsdParserException.CreateFmt('Invalid "maxOccurs" value : "%s.%s".',[FTypeName,locName]);
raise EXsdParserException.CreateFmt(SERR_InvalidMaxOccursValue,[FTypeName,locName]);
if ( locMinOccur < 0 ) then
raise EXsdParserException.CreateFmt('Invalid "maxOccurs" value : "%s.%s".',[FTypeName,locName]);
raise EXsdParserException.CreateFmt(SERR_InvalidMaxOccursValue,[FTypeName,locName]);
end;
end;
isArrayDef := locMaxOccurUnbounded or ( locMaxOccur > 1 );
@ -1267,18 +1267,18 @@ var
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_name)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if not locPartCursor.MoveNext() then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : missing "name" attribute.',[s_attribute]);
raise EXsdInvalidDefinitionException.Create(SERR_InvalidAttributeDef_MissingName);
locName := (locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
if IsStrEmpty(locName) then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : empty "name".',[s_attribute]);
raise EXsdInvalidDefinitionException.Create(SERR_InvalidAttributeDef_EmptyName);
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_type)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if not locPartCursor.MoveNext() then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : missing "type" attribute.',[s_attribute]);
raise EXsdInvalidDefinitionException.Create(SERR_InvalidAttributeDef_MissingType);
locTypeName := ExtractNameFromQName((locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue);
if IsStrEmpty(locTypeName) then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : empty "type".',[s_attribute]);
raise EXsdInvalidDefinitionException.Create(SERR_InvalidAttributeDef_EmptyType);
locType := FSymbols.FindElement(locTypeName) as TPasType;
if not Assigned(locType) then begin
locType := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,locTypeName,Self.Module.InterfaceSection,visPublic,'',0));
@ -1291,10 +1291,10 @@ var
if locPartCursor.MoveNext() then begin
locStoreOpt := ExtractNameFromQName((locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue);
if IsStrEmpty(locStoreOpt) then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : empty "use".',[s_attribute]);
raise EXsdInvalidDefinitionException.Create(SERR_InvalidAttributeDef_EmptyUse);
locStoreOptIdx := AnsiIndexText(locStoreOpt,[s_required,s_optional,s_prohibited]);
if ( locStoreOptIdx < 0 ) then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid <%s> definition : invalid "use" value "%s".',[s_attribute,locStoreOpt]);
raise EXsdInvalidDefinitionException.CreateFmt(SERR_InvalidAttributeDef_InvalidUse,[locStoreOpt]);
end else begin
locStoreOptIdx := 1{optional by default!}; //0;
end;
@ -1325,7 +1325,7 @@ var
begin
ExtractBaseType();
if not ( FDerivationMode in [dmExtension, dmRestriction] ) then
raise EXsdInvalidTypeDefinitionException.Create('Invalid "complexeType.simpleType" definition : restriction/extension not found.');
raise EXsdInvalidTypeDefinitionException.Create(SERR_InvalidComplexSimpleTypeDef_NoRestOrExt);
internalName := ATypeName;
hasInternalName := IsReservedKeyWord(internalName) or
@ -1396,7 +1396,7 @@ var
locContinue : Boolean;
begin
if not AnsiSameText(ExtractNameFromQName(FTypeNode.NodeName),s_complexType) then
raise EXsdParserAssertException.CreateFmt('%s expected but %s found.',[s_complexType,ExtractNameFromQName(FTypeNode.NodeName)]);
raise EXsdParserAssertException.CreateFmt(SERR_ExpectedButFound,[s_complexType,ExtractNameFromQName(FTypeNode.NodeName)]);
Result := nil;
CreateNodeCursors();
ExtractTypeName();
@ -1404,7 +1404,7 @@ begin
locSym := FSymbols.FindElement(FTypeName);
if Assigned(locSym) then begin
if not locSym.InheritsFrom(TPasType) then
raise EXsdParserException.CreateFmt('Symbol found in the symbol table but is not a type definition : %s.',[FTypeName]);
raise EXsdParserException.CreateFmt(SERR_ExpectedTypeDefinition,[FTypeName]);
locContinue := locSym.InheritsFrom(TPasUnresolvedTypeRef) or
( IsEmbeddedType(TPasType(locSym)) <> FEmbededDef );
if not locContinue then;
@ -1450,11 +1450,11 @@ begin
);
locCrs.Reset();
if not locCrs.MoveNext() then
raise EXsdParserAssertException.Create('Unable to find the <name> tag in the type node attributes.');
raise EXsdParserAssertException.Create(SERR_UnableToFindNameTagInNode);
FTypeName := (locCrs.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
end;
if IsStrEmpty(FTypeName) then
raise EXsdParserAssertException.Create('Invalid type name( the name is empty ).');
raise EXsdParserAssertException.Create(SERR_InvalidTypeName);
end;
function TSimpleTypeParser.ExtractContentType() : Boolean;
@ -1497,12 +1497,12 @@ begin
FIsEnum := True;
end else begin
if IsStrEmpty(FBaseName) then
raise EXsdParserAssertException.CreateFmt('Base type is not specified for the simple type, parsing : "%s".',[FTypeName]);
raise EXsdParserAssertException.CreateFmt(SERR_BaseTypeNotSpecfifiedForSimpleType,[FTypeName]);
FIsEnum := False
end;
end else begin
if IsStrEmpty(FBaseName) then
raise EXsdParserAssertException.CreateFmt('Base type is not specified for the simple type, parsing : "%s".',[FTypeName]);
raise EXsdParserAssertException.CreateFmt(SERR_BaseTypeNotSpecfifiedForSimpleType,[FTypeName]);
FIsEnum := False
end;
Result := True;
@ -1538,10 +1538,10 @@ var
begin
locCrs := CreateCursorOn(CreateAttributesCursor(AItemNode,cetRttiNode),ParseFilter(Format('%s=%s',[s_NODE_NAME,QuotedStr(s_value)]),TDOMNodeRttiExposer)) as IObjectCursor;
if not Assigned(locCrs) then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid "enum" item node : no value attribute, type = "%s".',[FTypeName]);
raise EXsdInvalidDefinitionException.CreateFmt(SERR_InvalidEnumItemNode_NoValueAttribute,[FTypeName]);
locCrs.Reset();
if not locCrs.MoveNext() then
raise EXsdInvalidDefinitionException.CreateFmt('Invalid "enum" item node : no value attribute, type = "%s".',[FTypeName]);
raise EXsdInvalidDefinitionException.CreateFmt(SERR_InvalidEnumItemNode_NoValueAttribute,[FTypeName]);
tmpNode := (locCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject;
locItemName := tmpNode.NodeValue;
{ (26-06-2008) empty string "" can be valid enum item!
@ -1611,7 +1611,7 @@ var
tmpElement : TPasElement;
begin // todo : implement TSimpleTypeParser.ParseOtherContent
if IsStrEmpty(FBaseName) then
raise EXsdInvalidTypeDefinitionException.CreateFmt('Invalid simple type definition : base type not provided, "%s".',[FTypeName]);
raise EXsdInvalidTypeDefinitionException.CreateFmt(SERR_BaseTypeNotSpecfifiedForSimpleType,[FTypeName]);
intrName := ExtractIdentifier(FTypeName);
hasIntrnName := ( intrName <> FTypeName ) or
IsReservedKeyWord(intrName);
@ -1640,7 +1640,7 @@ var
locContinue : Boolean;
begin
if not AnsiSameText(ExtractNameFromQName(FTypeNode.NodeName),s_simpleType) then
raise EXsdParserAssertException.CreateFmt('%s expected but %s found.',[s_simpleType,ExtractNameFromQName(FTypeNode.NodeName)]);
raise EXsdParserAssertException.CreateFmt(SERR_ExpectedButFound,[s_simpleType,ExtractNameFromQName(FTypeNode.NodeName)]);
Result := nil;
CreateNodeCursors();
ExtractTypeName();
@ -1648,7 +1648,7 @@ begin
locSym := FindElement(FTypeName);
if Assigned(locSym) then begin
if not locSym.InheritsFrom(TPasType) then
raise EXsdParserAssertException.CreateFmt('Symbol found in the symbol table but is not a type definition : %s.',[FTypeName]);
raise EXsdParserAssertException.CreateFmt(SERR_ExpectedTypeDefinition,[FTypeName]);
locContinue := locSym.InheritsFrom(TPasUnresolvedTypeRef);
if not locContinue then begin
Result := locSym as TPasType;

View File

@ -20,10 +20,13 @@ const
sWST_SIGNATURE = 'WST_METADATA_0.6';
resourcestring
SERR_BaseTypeNotSpecfifiedForSimpleType = 'Base type is not specified for the simple type, parsing : "%s".';
SERR_CannotMakeInternalSymbolName ='Unable to make an internal symbol Name from "%s".';
SERR_CannotResolveNamespace = 'Unable to resolve this namespace : "%s".';
SERR_DataFilterNotFound = 'Data Filter not found : "%s".';
SERR_DuplicateBindingName = 'Duplicated binding : "%s".';
SERR_ExpectedButFound = '%s expected but %s found.';
SERR_ExpectedTypeDefinition = '"%s" was expected to be a type definition.';
SERR_ExpectingRemotableObjectClass = 'Expecting remotable object class but found "%s".';
SERR_FailedTransportRequest = '%s Request to %s failed.';
SERR_HeaderNotUnderstood = 'Header "%s" not Understood.';
@ -32,11 +35,26 @@ resourcestring
SERR_IncompleteParamTypeRegistration = 'Incomplete type registration for the type of this parameter : "%s".';
SERR_InnerScopeMustBeSimpleType = 'Inner Scope value must be a "simple type" value.';
SERR_InvalidArrayBounds = 'Invalid array bounds.';
SERR_InvalidArrayItemType = 'Invalid array type definition, invalid item type definition : "%s".';
SERR_InvalidArrayLength = 'Invalid array length : %d.';
SERR_InvalidAttributeDef_EmptyName = 'Invalid Attribute definition : empty "name".';
SERR_InvalidAttributeDef_EmptyType = 'Invalid Attribute definition : empty "type".';
SERR_InvalidAttributeDef_EmptyUse = 'Invalid Attribute definition : empty "use".';
SERR_InvalidAttributeDef_InvalidUse = 'Invalid Attribute definition : invalid "use" value "%s".';
SERR_InvalidAttributeDef_MissingName = 'Invalid Attribute definition : missing "name" attribute.';
SERR_InvalidAttributeDef_MissingType = 'Invalid Attribute definition : missing "type" attribute.';
SERR_InvalidCollectionLength = 'Invalid collection length : %d.';
SERR_InvalidComplexSimpleTypeDef_NoRestOrExt = 'Invalid "complexeType.simpleType" definition : restriction/extension not found.';
SERR_InvalidDataTypeInContext = 'Invalid data type in this context : "%s".';
SERR_InvalidElementDef_MissingNameOrRef = 'Invalid <element> definition : missing "name" or "ref" attribute.';
SERR_InvalidElementDef_EmptyName = 'Invalid <element> definition : empty "name".';
SERR_InvalidElementDef_EmptyType = 'Invalid <element> definition : empty "type".';
SERR_InvalidElementDef_Type = 'Invalid <element> definition : unable to determine the type. Type name : "%s"; Element name :"%s".';
SERR_InvalidEncodedData = 'Invalid encoded data.';
SERR_InvalidEnumItemNode_NoValueAttribute = 'Invalid "enum" item node : no value attribute, type = "%s".';
SERR_InvalidHourOffetValue = '"%d" is not a valid hour offset value.';
SERR_InvalidMaxOccursValue = 'Invalid "maxOccurs" value : "%s.%s".';
SERR_InvalidMinOccursValue = 'Invalid "minOccurs" value : "%s.%s".';
SERR_InvalidMinuteOffetValue = '"%d" is not a valid minute offset value.';
SERR_InvalidEmbeddedScopeOperation = 'Invalid opération on scope, their are no embedded scope.';
SERR_InvalidParameter = 'Invalid parameter : "%s".';
@ -44,6 +62,11 @@ resourcestring
SERR_InvalidParameterProc = 'Invalid parameter : "%s"; Procedure = "%s".';
SERR_InvalidParameters = 'Invalid parameters.';
SERR_InvalidPoolParametersArgs = 'Invalid pool arguments Min = %d; Max = %d .';
SERR_InvalidTypeDef_AttributeNotFound = 'Invalid type definition, attributes not found : "%s".';
SERR_InvalidTypeDef_BaseAttributeNotFound = 'Invalid extention/restriction of type "%s" : "base" attribute not found.';
SERR_InvalidTypeDef_NamedAttributeNotFound = 'Invalid type definition, unable to find the "%s" attribute : "%s".';
SERR_InvalidTypeDef_NoChild = 'Invalid type definition, this element must have children.';
SERR_InvalidTypeName = 'Invalid type/element name( the name is empty ).';
SERR_IsNotAFieldOf = '"%s" is not a field of "%s".';
SERR_NodeNotFoundByID = 'Node not found with this ID in the document : "%s".';
SERR_NoHandlerForThatVerb = 'No handler for that verb : "%s".';
@ -59,6 +82,8 @@ resourcestring
SERR_ServiceNotFound = 'Service not found : "%s".';
SERR_ScopeNotFound = 'Scope not found : "%s".';
SERR_TypeNotRegistered = 'Type not registered : "%s".';
SERR_TypeStyleNotSupported = 'This type style is not supported : "%s".';
SERR_UnableToFindNameTagInNode = 'Unable to find the <name> tag in the type/element node attributes.';
SERR_UnexpectedEndOfData = 'Unexpected end of data.';
SERR_UnknownProperty = 'Unknown property : "%s".';
SERR_UnsupportedOperation = 'Unsupported operation : "%s".';