Is it possible to pass a custom error code with plpy.error/fatal
or inherit SPIError
to pass a custom ERRCODE, HINT, etc?
While poking through the plpython source, a way I found so far, is to inherit from SPIError and set sqlstate
raise type('MyError', (plpy.SPIError,), {'sqlstate': 'D000M'})(...)
will propagate the ERRCODE D000M
and works for me.
A nice to have would be to define a custom HINT too but looks more tricky, since it comes with spidata
.