pastojs: fixed handling read error

git-svn-id: trunk@40108 -
This commit is contained in:
Mattias Gaertner 2018-10-31 14:17:39 +00:00
parent 1eb6ef4b27
commit 0e012e657f
2 changed files with 23 additions and 2 deletions

View File

@ -1206,6 +1206,9 @@ function TPas2jsCachedFile.Load(RaiseOnError: boolean; Binary: boolean
procedure Err(const ErrorMsg: string);
begin
{$IFDEF VerboseFileCache}
writeln('TPas2jsCachedFile.Load.Err ErrorMsg="',ErrorMsg,'"');
{$ENDIF}
FLastErrorMsg:=ErrorMsg;
if RaiseOnError then
raise EPas2jsFileCache.Create(FLastErrorMsg);
@ -1213,6 +1216,7 @@ function TPas2jsCachedFile.Load(RaiseOnError: boolean; Binary: boolean
var
NewSource: string;
b: Boolean;
begin
{$IFDEF VerboseFileCache}
writeln('TPas2jsCachedFile.Load START "',Filename,'" Loaded=',Loaded);
@ -1250,7 +1254,18 @@ begin
exit;
end;
NewSource:='';
if not Cache.ReadFile(Filename,NewSource) then exit;
if RaiseOnError then
b:=Cache.ReadFile(Filename,NewSource)
else
try
b:=Cache.ReadFile(Filename,NewSource);
except
end;
if not b then begin
Err('Read error "'+Filename+'"');
exit;
end;
{$IFDEF VerboseFileCache}
writeln('TPas2jsCachedFile.Load ENCODE ',Filename,' FFileEncoding=',FFileEncoding);
{$ENDIF}
@ -1799,6 +1814,7 @@ begin
except
raise EReadError.Create(String(JSExceptValue));
end;
Result:=true;
{$ELSE}
ms:=TMemoryStream.Create;
try

View File

@ -59,7 +59,12 @@
</Debugging>
</Linking>
<Other>
<CustomOptions Value="-Jeutf-8 -Jc"/>
<CustomOptions Value="-Jeutf-8
-Jc
-dVerboseFileCache"/>
<OtherDefines Count="1">
<Define0 Value="VerboseFileCache"/>
</OtherDefines>
<CompilerPath Value="$(pas2js)"/>
</Other>
</CompilerOptions>