[dojo-contributors] Stance on custom error types

Bryan Forbes bryan at reigndropsfall.net
Wed Jun 6 07:46:14 EDT 2012


It looks good, however I'm working on some changes to the internals to
dojo/request which would change how errors are passed around. I like
dojo/errors and will move the errors I have created locally to that
directory.

-Bryan

Mark Wubben wrote:
> Any quick feedback on <https://github.com/novemberborn/dojo/compare/custom-errors>?
> 
> Adds `dojo/errors` to host the `CancelError` and `TimeoutError` classes. No magic helper to create the subclasses either. `dojoType` is still exposed for backwards compatibility, though it should be removed in 2.0 in favor of checking `name`.
> 
> On 4 Jun 2012, at 13:46, Ben Hockey wrote:
> 
>> i prefer custom errors too - for the reasons you mention.
>>
>> ben…
>>
>>
>> On Jun 4, 2012, at 8:41 AM, Mark Wubben wrote:
>>
>>> Dojo seems to do custom errors by adding a `dojoType` property to the error instance. Examples in `dojo/request` and `dojo/io`. The new Promise code however uses a subclassed Error.
>>>
>>> dojo/promise/CancelError:
>>>
>>> 	function CancelError(message){
>>> 		Error.captureStackTrace && Error.captureStackTrace(this, CancelError);
>>> 		this.message = message || "The deferred was cancelled.";
>>> 		this.name = "CancelError";
>>> 	};
>>> 	CancelError.prototype = new Error;
>>> 	CancelError.prototype.constructor = CancelError;
>>> 	return CancelError;
>>>
>>> I prefer subclassed errors because they're easier to instantiate and test for (either using `instanceof` or checking their `name`). We could even add `dojoType` properties.
>>>
>>> What is your preference?
>>>
>>> In any case, we need to standardize these across the codebase.
>>>
>>> --
>>> Mark Wubben
>>>
>>> http://novemberborn.net
>>> http://twitter.com/novemberborn
>>>
>>> _______________________________________________
>>> dojo-contributors mailing list
>>> dojo-contributors at mail.dojotoolkit.org
>>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
>> _______________________________________________
>> dojo-contributors mailing list
>> dojo-contributors at mail.dojotoolkit.org
>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
> 
> --
> Mark Wubben
> 
> http://novemberborn.net
> http://twitter.com/novemberborn
> 
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors


-- 
Bryan Forbes
http://www.reigndropsfall.net

GPG Fingerprint
3D7D B728 713A BB7B B8B1  5B61 3888 17E0 70CA 0F3D

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20120606/3e2ddff2/attachment.sig 


More information about the dojo-contributors mailing list