Exceptions checking
Bart Pietercil
bart.pietercil at cognosis.be
Fri Sep 12 05:57:55 CDT 2008
Hi Ivan,
On 12 Sep 2008, at 11:30, Ivan Smahin wrote:
>>
>
>> 1) Can I use the <description> in Stored Procedures instead of the
>> numbers (much clearer) as they are defined in the sql_errors.xml and
>> kernel_errors.xml.
>
> Yes, you can use both.
OK
>
>
>> 2) Do I understand correctly that both files are used in exception
>> checking ?
>
> Right.
>
>> If yes then why are there 2 files instead of 1 with all the
>> exceptions ?
>
> Because of planning to split API and SQL ways in the future.
OK
>
>
>> 3) Do I understand correctly that we can edit the <GROUP name="User-
> defined errors">> in order to raise our own exceptions (as long as we
>> stay in the predefined range)
>
> No, you could not add new states in this way. Instead you should
> raise something like 0x50001, 0x50002 ...
> Sure you can do following inside the sp:
>
> DECLARE MY_STATE as long;
> SET MY_STATE = 0x50001;
> ...
>
> RAISE MY_STATE;
> ...
aha
>
>
>> Maybe as a feature request there could be a third file named
>> user_defined_errors.xml that would need to have the same structure as
>> the other two.
>> Difference would be that Paradigma can while updating replace the
>> two
>> 'standard' files without overwriting the user_defined_errors.xml.
>
> Well, actually that XMLs play two roles
> 1. We use them for generating some C++ sources for "error" processing.
> 2. You could use it for getting some explanations.
>
> Having one "user-Defined.xml" we should processing it in runtime.
>
> On the other hand - there is a way to define own "states" inside SPs
> or tables. It is something like special for particular project states.
> It could not be common ones.
>
>> 4) Do I understand correctly that in order to be used these files
>> HAVE
>> to reside in the vresources directory.
>
> Yes.
>
>> 5) Can a stored procedure return the <message> and <comments> xml
>> nodes to the calling client ?
>
>
>> If YES how ?
>
>> If NO we will return the error to the calling client (in our case
>> php)
>
>> a) can we do this like this:
>
>> EXCEPTION
>> WHEN ERR_CONSTRAINT_UNIQUE_VIOLATION THEN
>> return ERR_CONSTRAINT_UNIQUE_VIOLATION
>> END;
>
> Look, you are catching the exception and going to pass it outside.
> Probably you should just let it go self? In this case client will get
> an exception as usual.
>
> --
Well no I think:
Look what we need to do is have error.xml files for all our interface
languages (for the moment three)
So I need to have in case of an exception inside my procedure THAT
ENDS THE PROCEDURE (let's say a duplicate in a unique) I would like to
return to PHP the errorcode
Then PHP can decide based on the clients language wat error message
will be displayed (english, dutch or french).
Therefore I think we need our 3 edited (for language) own copies of
error.xml inside our language specific directories.
So when php calls a stored procedure I can have a fallback like this
EXCEPTION
WHEN OTHERS THEN
return @@LastErrorCode
END;
Then php can pick up the errorcode and proces for the appropriate
language.
Will this work ?
tia
Bart
More information about the Valentina
mailing list