Jump to content
Fr0sT.Brutal

Weird fragment in TCustomWSocket.RaiseException

Recommended Posts

        MyException := ESocketException.Create(MyMessage, AErrorCode, AErrorMessage,
                                               AFriendlyMsg, AFunc, AIP, APort, AProto);
        if Assigned (FonException) then
        begin
            TriggerException (MyException) ;       { V8.36 }
        end
        else
        begin
            TriggerException (MyException) ;       { V8.37 }
            raise MyException;
        end;
        if Assigned (MyException) then MyException.Free;  { V8.37 }
    end;
end;

This fragment looks pretty weird for me

1 - TriggerException is called always so could be lifted before `if Assigned`

2 - `if Assigned (MyException)` is useless because it's created several lines earlier

Wouldn't this be the shorter equivalent?

        MyException := ESocketException.Create(MyMessage, AErrorCode, AErrorMessage,
                                               AFriendlyMsg, AFunc, AIP, APort, AProto);
        TriggerException (MyException) ;       { V8.36 }
        if not Assigned (FonException) then
            raise MyException;
        MyException.Free;  { V8.37 }

 

Edited by Fr0sT.Brutal

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×