> Invariably when writing my own code I forget to check
> chrome.extension.lastError in my callback and die horribly at the first
> attempt to reference a parameter on the callback.  If they do something like
> store a reference to the callback parameters in a container for later
> processing then the undefined reference might not show up until much much
> later and be impossible to track down.  In cases where the callback is
> parameterless (for example chrome.tabs.update()) an extensions developer
> will typically forget to check lastError and proceed with their application
> logic regardless of if the call succeeded.  This seems less than ideal :(
>

Omitting error handling code in the case of separate success & error
callbacks has the result that the call simply disappears into nowhere and no
resulting code ever runs. If an error has occurred, it seems to me like the
more obvious failure is preferable.

In either case, an async call error will always generate a console.error()
message.

On Tue, Aug 25, 2009 at 1:44 PM, James Robinson <[email protected]> wrote:

> On Tue, Aug 25, 2009 at 4:03 PM, Aaron Boodman <[email protected]> wrote:
>
>> Thanks for the feedback, James.
>>
>> Part of the motivation for this design was that errors are (or at
>> least should be) rare, and so we should not overoptimize the paths for
>> handling them.
>
>
> Hopefully error will be vanishingly rare, but some errors are unavoidable.
>  Errors that are rare also tend to be less likely to show up in the
> development cycle which makes it more tempting to not code for error paths
> and blow up horribly in the wild (I didn't catch the chrome.tabs.create()
> error condition until trying on a different machine).
>

I think it's true that these errors will tend to be very rare. I feel like
it's nearly impossible to handle an error in some useful way without
understanding the error case. Can you give an example of doing something
useful in handling an error that will typically only be discovered "in the
wild"?

My worry is that if we encourage developers to always handle errors,
extension code will be more verbose, but almost never do anything other than
report the error somewhere (which already happens).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to