haxe-coroutines icon indicating copy to clipboard operation
haxe-coroutines copied to clipboard

Error handling

Open RealyUniqueName opened this issue 7 years ago • 2 comments

Think about exception proagation scenarios.

RealyUniqueName avatar Aug 25 '17 11:08 RealyUniqueName

Also think about error handling without exceptions. On some targets, especially cpp, exceptions are prohibitively expensive.

ousado avatar Sep 18 '17 21:09 ousado

Error handling is a tricky subject indeed. Most often (e.g. js,c#,kotlin) it's implemented in coroutines by using try/catch syntax, which is a "natural" way to handle errors in the imperative code. But, even performance aside, it seems to be compromising type safety for syntax consistency in some cases. For example, if we have some API that returns Future<Either<MyResult,MyError>> (I think tink libraries do that), we know the exact type of an error we want to handle (MyError), while try/catch is a generic way to catch any error, which might be less clear and more error-prone. I'm not sure if this is a valid concern or what would be an alternative though, I guess we'll have to make some compromises here...

nadako avatar Sep 18 '17 22:09 nadako