#1 2015-05-17 15:03:32

GetCoffee
Member
Registered: 2014-09-20
Posts: 9

mORMot and ZEOS error handling.

Hello,

I`m trying to investigate how should i handle connection errors code. Especially with postgresql such as bad database name, invalid user password etc. Any advice? The exceptions doesnt have any code errors just, a message, wich can be either in English or other language depending on pgsql so its not a good way to check it. ZdbcPostgreSqlUtils: CheckPostgreSQLError

Thanks in advance.

Offline

#2 2015-05-17 18:16:15

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

Re: mORMot and ZEOS error handling.

I usually define my own Exception class, with its own set of high-level errors, if needed.
Then I could check the exact error from an enumeration value, in a:

try
...
except 
  on E: EMyExtendedClass do 
  begin
   ...
   case E.AdvancedErrorCause of
   ...
   end;
  end;
end;

Then the addition information may be serialized as JSON - using published properties, e.g. to reproduce the full error message, or for logging, or for transmission as a REST service.

Offline

#3 2015-05-17 18:24:21

GetCoffee
Member
Registered: 2014-09-20
Posts: 9

Re: mORMot and ZEOS error handling.

Hi, thanks for the reply.

So it seems that the zeos postgresql (maybe others) implementation should be extended as there is a ZSQLException but without any status code in the estabilishment of a connection part.

Offline

Board footer

Powered by FluxBB