Re: [gdome]Exception Codes again



Paolo wrote:
> So I thought to implement all Exception types in only one gulong
> variables. So we can have 256 availables possible codes for each kind of
> Exceptions.
> 
> Examples:
> 0 no core exception
> 1 the first core exception
> 2 ...
> ...
> 256 no event exception
> 257 the first event exception
> 258...
> ...
> and so on....
> 
> any other implementation that deal with different kind of exception in
> only one variables are possible...
> 
> suggestions will be appreciated!

Hi Paolo,

my (maybe naive) impression when reading the W3C-DOMEvents recommendation
was that code 0 was chosen for UNSPECIFIED_EVENT... with the intention
that it does not interfere with existing exception codes of the core
module.

But now I searched and learned that Exception codes in other modules do
interfere with the Core Exception codes. Sorry, I should have done that
before I wrote my last mail.


> 256 no event exception

This constant is not nececcary.

What about:

enum Core_Exception{... /* as currently implemented */)
enum Event_Exception{UNSPECIFIED_EVENT_TYPE_ERR = 0};
enum XPath_Exception{INVALID_EXPRESSION_ERR = 1,
                     TYPE_ERR               = 2};
enum Exception_Type{CORE_EXCEPTION  = 0 << 16,
                    EVENT_EXCEPTION = 1 << 16,
                    XPATH_EXCEPTION = 2 << 16};
enum Exception_Masks{EXCEPTION_TYPE_MASK = 255 << 16,
                     EXCEPTION_CODE_MASK = 65535};

then, after a gdome function call
if (exc != 0) {
  Gdome_Excpetion exc_type = exc & EXCEPTION_TYPE_MASK;
  Gdome_Excpetion exc_code = exc & EXCEPTION_CODE_MASK;
  switch(exc_type){
	case ...
  }
}

In some way, this would be compliant to the DOM recommendation, since
(unsigned short)exc yields the correct exception code (with the IDL
definition of unsigned short, being 16 bits, of course).

Bye, Tobias






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]