Hi,

I would like to ask about an exception handling policy in JSC C API implementation.

After checking the code I found a common pattern:

(A)

if (exec->hadException()) {

if (exception)

*exception = toRef(exec, exec->exception());

exec->clearException();

}

Which means that exception handler value is set only when an exception occurs. Another approach that I found is in JSValueCreateJSONString:

(B)

if (exception)

*exception = 0;

if (exec->hadException()) {

if (exception)

*exception = toRef(exec, exec->exception());

exec->clearException();

}

That code always set exception handler. Advantage of this solution (B) is that after call, an api user can check if actually an exception occured by checking value of the exception handler (it was possible with the first approach (A) by initialize exception handler to null, but it is rather a side effect). The B pattern is not optimal, because the exception handler may be reinitialized.

I believe that an exception handler should be used for simple error checking;

- there is not null exception value => it means that returned value is not valid, because of an error.

- there is null exception => everything is ok.

What do you think about code C?

(C)

if (exception) {

if (exec->hadException()) {

*exception = toRef(exec, exec->exception());

exec->clearException();

} else

*exception = 0;

} else

exec->clearException();

In this case exception handler is always set correctly. Would it make sense to change the behavior? The change unifies interface and is binary compatible. It shouldn't break a correct code... :-)

Cheers,

Jędrek