* overloaded version of raiselastoserror that allows custom errorcodes

to be raised, patch by Cytax, Mantis #21092

git-svn-id: trunk@20084 -
This commit is contained in:
marco 2012-01-15 11:54:12 +00:00
parent 96e8e89e16
commit 1f40ff2362
2 changed files with 21 additions and 13 deletions

View File

@ -19,7 +19,8 @@ Type TExecuteFlags = Set of ( ExecInheritsHandles);
{$ifdef HAS_OSERROR}
Function GetLastOSError : Integer;
{$endif}
Procedure RaiseLastOSError;
Procedure RaiseLastOSError;overload;
Procedure RaiseLastOSError(LastError: Integer);overload;
Function GetEnvironmentVariable(Const EnvVar : String) : String;
Function GetEnvironmentVariableCount : Integer;
Function GetEnvironmentString(Index : Integer) : String;

View File

@ -408,27 +408,34 @@ begin
end;
{$IFDEF HAS_OSERROR}
Procedure RaiseLastOSError;
var
ECode: Cardinal;
E : EOSError;
Procedure RaiseLastOSError;overload;
begin
ECode := GetLastOSError;
If (ECode<>0) then
E:=EOSError.CreateFmt(SOSError, [ECode, SysErrorMessage(ECode)])
RaiseLastOSError(GetLastOSError);
end;
Procedure RaiseLastOSError(LastError: Integer);overload;
var
E : EOSError;
begin
If (LastError<>0) then
E:=EOSError.CreateFmt(SOSError, [LastError, SysErrorMessage(LastError)])
else
E:=EOSError.Create(SUnkOSError);
E.ErrorCode:=ECode;
E.ErrorCode:=LastError;
Raise E;
end;
{$else}
Procedure RaiseLastOSError;
{$else}
Procedure RaiseLastOSError;overload;
begin
Raise Exception.Create('RaiseLastOSError not implemented on this platform.');
end;
Procedure RaiseLastOSError(LastError: Integer);overload;
begin
RaiseLastOSError;
end;
{$endif}
Procedure AssertErrorHandler (Const Msg,FN : ShortString;LineNo:longint; TheAddr : pointer);
Var