Leon Starr <leon_starr@modelint.com> writes:
> db=# select test_input('blue');
> ERROR: invalid input value for enum side: "blue"
> 1) What is the actual name of the condition (and, yes, I looked through appendix A trying to figure it out) for
invalidenum input?
[ looks at code... ] Try INVALID_TEXT_REPRESENTATION.
> 2) Is there a way to retrieve the error code so that I don't have to guess at the condition name? (I've been playing
thisgame a lot with other exceptions and I don't understand WHY the condition or code isn't provided when an untrapped
erroroccurs) Clearly, I'm missing something!
In psql, you can do this:
regression=# CREATE TYPE side AS ENUM ('right', 'left');
CREATE TYPE
regression=# select 'blue'::side;
ERROR: invalid input value for enum side: "blue"
LINE 1: select 'blue'::side;
^
regression=# \set VERBOSITY verbose
regression=# select 'blue'::side;
ERROR: 22P02: invalid input value for enum side: "blue"
LINE 1: select 'blue'::side;
^
LOCATION: enum_in, enum.c:56
and after that, you can either look up the SQLSTATE 22P02 in appendix A,
or consult the source code in enum_in(). If you're not using psql, the
same information should be available through the client API you're using
--- feel free to complain to its authors if not.
regards, tom lane