* 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} {$ifdef HAS_OSERROR}
Function GetLastOSError : Integer; Function GetLastOSError : Integer;
{$endif} {$endif}
Procedure RaiseLastOSError; Procedure RaiseLastOSError;overload;
Procedure RaiseLastOSError(LastError: Integer);overload;
Function GetEnvironmentVariable(Const EnvVar : String) : String; Function GetEnvironmentVariable(Const EnvVar : String) : String;
Function GetEnvironmentVariableCount : Integer; Function GetEnvironmentVariableCount : Integer;
Function GetEnvironmentString(Index : Integer) : String; Function GetEnvironmentString(Index : Integer) : String;

View File

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