[whatwg] Structured clone for an Error object

Simon Pieters simonp at opera.com
Sun Feb 28 22:32:56 PST 2010


On Sun, 28 Feb 2010 23:03:31 +0100, ATSUSHI TAKAYAMA  
<taka.atsushi at googlemail.com> wrote:

> On Fri, Feb 26, 2010 at 1:44 PM, Drew Wilson <atwilson at google.com> wrote:
>> BTW, the spec says that unhandled exceptions are either propagated to  
>> the
>> parent Worker object (in the case of dedicated workers) or reported to  
>> the
>> user via the console (for shared workers).
>> So I'm not certain why passing Error objects via postMessage() would be
>> necessary for a spec-compliant UA (note that some UAs have bugs in their
>> implementation such that not all exceptions in Workers are logged to the
>> console, but that shouldn't motivate a change in the spec).
>> -atw
>
> This is good to know. As far as I tested, Firefox and Safari actually
> supports worker.onerror.
>
> It also turns out that Firefox and Chromium actually sends a clone of
> an Error object. Safari turns it into a string. Are they going to
> convert change the behavior in the future?

Internal builds of Opera converts Error to null as the spec says, but we'd  
be happy to see the spec changed to say that Error, DOMException, and  
similar things get cloned.

If you want to make sure your current code will continue to work, you  
should probably toString() explicitly before postMessage()ing.

-- 
Simon Pieters
Opera Software



More information about the whatwg mailing list