> ## Content Index
> Fetch the complete content index at: https://blogs.remobjects.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Useful Chrome language feature: Conditional exception handlders
- URL: https://blogs.remobjects.com/2007/12/06/useful-chrome-language-feature-conditional-exception-handlders/
- Published: 2007-12-06T13:00:02.000Z
- Updated: 2018-08-22T06:17:48.000Z
- Author: Carlo Kok
- Tags: #Import 2026-08-17 20:17

A conditional exception handler is an on e: … do block in an exception handler that has a where condition. This allows you to only catch an exception when all your conditions apply to it. Although we’ve had this feature since the first version of Chrome, it’s not a very well known.

///

Reads data from a socket. Returns 0 when the socket was disconnected or reset by peer class method Utilities.ReadData(Sock: Socket; Data: array of Byte): Integer; begin try Result := Sock.Receive(Data, 0, Data.Length, SocketFlags.None); except on e: SocketException where e.ErrorCode = 10054 do Result := 0; // Reset by peer end; end;

Above block reads data from a socket, but it catches the “Reset by peer” exception, and returns 0, like it’s a regular disconnect.