event-loop icon indicating copy to clipboard operation
event-loop copied to clipboard

Specify error cases

Open kelunik opened this issue 8 years ago • 6 comments

Currently we do not specify error cases apart from invalid watcher IDs, e.g. what happens on a negative or 0 interval for timers, what happens on a wrong type there, etc.

kelunik avatar Jan 06 '17 13:01 kelunik

I don't think we need to specify wrong types.

It makes sense to explicitly specify negative integers being unspecified.

(A zero interval for timers is pretty straightforward … it gets executed again after 0 time, i.e. in the next tick - which is implied by the current wording...)

bwoebi avatar Jan 06 '17 16:01 bwoebi

It makes sense to explicitly specify negative integers being unspecified.

Why does this make sense?!

kelunik avatar Jan 06 '17 16:01 kelunik

Looks like we should also include 0 here, the underlying loop backends don't seem to be able to handle that well.

bwoebi avatar Jan 06 '17 16:01 bwoebi

I think it would be good if all loop implementations handled these edge cases the same way, including numeric strings such as '1' being passed as delays/intervals. We don't want applications breaking when someone swaps loop implementations because the unspecified behaviour is handled different by different loops. Perhaps we could add some logic to Driver which validates and sanitises inputs to ensure that all drivers treat these edge cases the same way.

joshdifabio avatar Jan 06 '17 16:01 joshdifabio

@kelunik Hmm, doesn't make much sense to have it completely unspecified - I think we should specify that they MUST throw a \Throwable|\Exception (but not what type of Throwable exactly they shall throw).

bwoebi avatar Jan 06 '17 17:01 bwoebi

@joshdifabio That's not an inherently bad idea, but it will have quite a footprint (e.g. extra function call) [also, not all functions receive args, so we'd have some functions directly being public API, others being protected…] … I'm not too much a fan of it.

bwoebi avatar Jan 06 '17 17:01 bwoebi