Re: Catching postgres exceptions - functions returning error values?
Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> writes:
> Now, if the database server is unavailable, I get something like this:
>
> org.postgresql.util.PSQLException: Connection refused. Check that the
> hostname and port are correct and that the postmaster is accepting
> TCP/IP connections.
>
> I would like to know, in my code, what happened, and inform user
> apropriatley, I don't want just to print the exception to the user.
What would like to substitute to the above message for instance? Is
this just a language issue?
> I could parse the return from printStackTrace method, but that just
> doesn't seem right.
>
> Also, some of the functions need to return errorcode of some sort. If
> the function is returning SETOF, I can't use OUT parametars. So, I'm
> asking for a recomendation here.
Maybe you want to use the SQLState
http://www.postgresql.org/docs/8.1/interactive/errcodes-appendix.html
http://www.easysoft.com/developer/interfaces/odbc/sqlstate_status_return_codes.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_error_codes.asp
http://www.opengroup.org/bookstore/catalog/c451.htm (appendix A)
http://www.opengroup.org/bookstore/catalog/c449.htm (appendix B)
Home |
Main Index |
Thread Index