rikulo/stream — pull request #15 by izaera (2013-04-05 06:08:17+00:00)
Title: Sample of experimental specification for controllers: let them return Future's

Hi developers:

This pull request is intended to show how it would be possible to allow controllers return Future's so that unhandled errors don't make the server crash. It's obviously not completely implemented (only one use case) as I haven't had time to look at all Stream's internals but you can get the feeling.

You can test it by writing a controller wich returns void and then throwing an error inside it. That will make the server return a 500 error instead of crashing.

Also, if you call async code inside the controller just throw an exception inside any then() block and you will get a 500 also. You can even chain some then()'s and don't write the catchError and it will still work as long as you return the last then's Future.

If you feel it makes sense please tell me and I will continue commiting changes until I refactor the whole thing. Or we can do it together, or you can do it alone. Whatever you prefer.

Regards,
Ivan