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

View File

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