pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedtranslating exception messages of postgresql functions
8+ messages / 3 participants
[nested] [flat]
* translating exception messages of postgresql functions
@ 2008-05-14 14:32 Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:01 ` Re: translating exception messages of postgresql functions Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 8+ messages in thread
From: Julius Tuskenis @ 2008-05-14 14:32 UTC (permalink / raw)
To: pgsql-admin
Hello,
I'd like to ask how is translation of raised exceptions done in
postgresql applications? In Sybase ASA you can specify the error
number when raising it, but in postgresql theres just exception message.
As I've read - postgresql always generates P0001 SQLSTATE code for
raised exceptions. Have enyone tried to distinguish one exception from
the other in the application?
--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
@ 2008-05-14 14:46 ` Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:22 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
1 sibling, 1 reply; 8+ messages in thread
From: Alvaro Herrera @ 2008-05-14 14:46 UTC (permalink / raw)
To: Julius Tuskenis <julius@nsoft.lt>; +Cc: pgsql-admin
Julius Tuskenis wrote:
> Hello,
>
> I'd like to ask how is translation of raised exceptions done in
> postgresql applications?
You want it translated or not translated?
> In Sybase ASA you can specify the error
> number when raising it, but in postgresql theres just exception message.
> As I've read - postgresql always generates P0001 SQLSTATE code for
> raised exceptions. Have enyone tried to distinguish one exception from
> the other in the application?
In Postgres 8.4 you will be able to specify error codes to raised
exceptions in PL/pgSQL.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
@ 2008-05-14 15:22 ` Julius Tuskenis <julius@nsoft.lt>
2008-05-14 15:33 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 1 reply; 8+ messages in thread
From: Julius Tuskenis @ 2008-05-14 15:22 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: pgsql-admin
Alvaro Herrera rašė:
> Julius Tuskenis wrote:
>
>> Hello,
>>
>> I'd like to ask how is translation of raised exceptions done in
>> postgresql applications?
>>
>
> You want it translated or not translated?
>
I want to translate the exception message. For example I raise an
exception in pg function like RAISE EXCEPTION 'my exception', then in my
application that calls the function I catch the exception. But before I
show it to the user of application I have to translate it. How do I know
what exception it is? As Tom Lane answered - the only way is to rely on
message text.
--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:22 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
@ 2008-05-14 15:33 ` Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:48 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
0 siblings, 1 reply; 8+ messages in thread
From: Alvaro Herrera @ 2008-05-14 15:33 UTC (permalink / raw)
To: Julius Tuskenis <julius@nsoft.lt>; +Cc: pgsql-admin
Julius Tuskenis wrote:
> I want to translate the exception message. For example I raise an
> exception in pg function like RAISE EXCEPTION 'my exception', then in my
> application that calls the function I catch the exception. But before I
> show it to the user of application I have to translate it. How do I know
> what exception it is? As Tom Lane answered - the only way is to rely on
> message text.
You want to translate it from english to another language, or you want
to change the nature of the message reported? If you just want to
translate it to another language, see here:
http://pgtranslation.projects.postgresql.org/status.html
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:22 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 15:33 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
@ 2008-05-14 15:48 ` Julius Tuskenis <julius@nsoft.lt>
2008-05-14 16:32 ` Re: translating exception messages of postgresql functions Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 8+ messages in thread
From: Julius Tuskenis @ 2008-05-14 15:48 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: pgsql-admin
Alvaro Herrera rašė:
> Julius Tuskenis wrote:
>
>
>> I want to translate the exception message. For example I raise an
>> exception in pg function like RAISE EXCEPTION 'my exception', then in my
>> application that calls the function I catch the exception. But before I
>> show it to the user of application I have to translate it. How do I know
>> what exception it is? As Tom Lane answered - the only way is to rely on
>> message text.
>>
>
> You want to translate it from english to another language, or you want
> to change the nature of the message reported? If you just want to
> translate it to another language, see here:
>
> http://pgtranslation.projects.postgresql.org/status.html
>
>
Thank you, Alvaro, but it seems you have slightly misunderstood me. I
want to translate the exceptions I rise myself. That is I do RAISE
EXCEPT 'user "%" not found', prm_user; in pl/pgsql function, but I want
the user to see it translated to the language he uses. Using whole error
message is inconvenient because the application gets 'user "Peter" not
found' or 'user "John" not found' - not 'user "%" not found'. Thats
where the problem is.
--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:22 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 15:33 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:48 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
@ 2008-05-14 16:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2008-05-14 16:41 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 1 reply; 8+ messages in thread
From: Tom Lane @ 2008-05-14 16:32 UTC (permalink / raw)
To: Julius Tuskenis <julius@nsoft.lt>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; pgsql-admin
Julius Tuskenis <julius@nsoft.lt> writes:
> Alvaro Herrera rašė:
>> You want to translate it from english to another language, or you want
>> to change the nature of the message reported? If you just want to
>> translate it to another language, see here:
>>
>> http://pgtranslation.projects.postgresql.org/status.html
>>
> Thank you, Alvaro, but it seems you have slightly misunderstood me. I
> want to translate the exceptions I rise myself. That is I do RAISE
> EXCEPT 'user "%" not found', prm_user; in pl/pgsql function, but I want
> the user to see it translated to the language he uses.
I wonder if it would help to make plpgsql pass the RAISE format string
through gettext?
This would only be a usable approach if there were some fairly easy way
to add installation-specific translations to gettext's table. I don't
know enough about gettext to know if that's doable.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:22 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 15:33 ` Re: translating exception messages of postgresql functions Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:48 ` Re: translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 16:32 ` Re: translating exception messages of postgresql functions Tom Lane <tgl@sss.pgh.pa.us>
@ 2008-05-14 16:41 ` Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 0 replies; 8+ messages in thread
From: Alvaro Herrera @ 2008-05-14 16:41 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Julius Tuskenis <julius@nsoft.lt>; pgsql-admin
Tom Lane wrote:
> I wonder if it would help to make plpgsql pass the RAISE format string
> through gettext?
Hmm, nice idea. However,
> This would only be a usable approach if there were some fairly easy way
> to add installation-specific translations to gettext's table. I don't
> know enough about gettext to know if that's doable.
There are lots of caveats -- the first being that you would need to
extract the messages from the function body. I don't think there's a
gettext PL/pgSQL parser, so there's a first hurdle there.
Then there's the matter of not mixing the "postgres" message domain with
the user's, so we would need to change it just before calling RAISE and
restore it afterwards.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: translating exception messages of postgresql functions
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
@ 2008-05-14 15:01 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 8+ messages in thread
From: Tom Lane @ 2008-05-14 15:01 UTC (permalink / raw)
To: Julius Tuskenis <julius@nsoft.lt>; +Cc: pgsql-admin
Julius Tuskenis <julius@nsoft.lt> writes:
> As I've read - postgresql always generates P0001 SQLSTATE code for
> raised exceptions. Have enyone tried to distinguish one exception from
> the other in the application?
You'd have to rely on looking at the error message text.
8.4 will let you specify SQLSTATE in RAISE:
http://developer.postgresql.org/pgdocs/postgres/plpgsql-errors-and-messages.html
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2008-05-14 16:41 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-05-14 14:32 translating exception messages of postgresql functions Julius Tuskenis <julius@nsoft.lt>
2008-05-14 14:46 ` Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:22 ` Julius Tuskenis <julius@nsoft.lt>
2008-05-14 15:33 ` Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:48 ` Julius Tuskenis <julius@nsoft.lt>
2008-05-14 16:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2008-05-14 16:41 ` Alvaro Herrera <alvherre@commandprompt.com>
2008-05-14 15:01 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox