#1 2025-04-11 11:17:23

Alek
Member
From: Russia
Registered: 2014-07-04
Posts: 56

How I can intercept ENetSock exception

Hello everyone

How I can intercept ENetSock exception in an example below?

https://gist.github.com/delphiapp/2e4ec … 123a6aa4ab

and one more small point

the file "store3.dto.pas"  is generated with errors from "OpenApiPetStore3.json"

Offline

#2 2025-04-11 12:13:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,955
Website

Re: How I can intercept ENetSock exception

1) You can add multiple exception classes to your except block, with a specific " on E: ENetSock do ... "

2) About errors, please try https://github.com/synopse/mORMot2/commit/1d3b1deaa

Offline

#3 2025-04-11 13:00:41

Alek
Member
From: Russia
Registered: 2014-07-04
Posts: 56

Re: How I can intercept ENetSock exception

1. I want to say, that an except block exist in the TSimpleHttpClient.Request method and it doesn't raise an exception higher. And my messagebox doesn't appear
2. It's ok

Last edited by Alek (2025-04-11 13:02:54)

Offline

#4 2025-04-11 13:38:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,955
Website

Re: How I can intercept ENetSock exception

But what should the method return in such state?

An exception seems like the right thing to do if the connection is broken, IMHO.

Offline

#5 2025-04-14 05:46:24

Alek
Member
From: Russia
Registered: 2014-07-04
Posts: 56

Re: How I can intercept ENetSock exception

Good morning

In my example, the RunClient function should catch all exceptions, including ENetSock. But it doesn't happen.

I wrote an example to show this.

Offline

#6 2025-04-14 07:35:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,955
Website

Re: How I can intercept ENetSock exception

Did you try to use the jcoHttpExceptionIntercept option?

Offline

#7 2025-04-14 10:02:36

Alek
Member
From: Russia
Registered: 2014-07-04
Posts: 56

Re: How I can intercept ENetSock exception

Yes, of course

Offline

Board footer

Powered by FluxBB