I don't think there is an optimal way to do that in iced coffee script, although that post has some interesting suggestions: Iced coffee script with multiple callbacks
I would just stick to vanilla coffee script:
This is how your function would be writtent in coffee-script
fun = (success_cb, error_cb) ->
try
result = function_that_calculates_result()
success_cb result
catch e
error_cb e
and how you would call it in coffee script
fun (result) ->
console.log result
, (error) ->
console.log error.message
If you can rewrite the fun function in an "errback" style (err, result) in coffee script, that would be:
fun = (callback) ->
try
result = function_that_calculates_result()
callback null, result
catch e
callback e
you would then use it like that in iced coffeescript
await fun defer error, result
if error
console.log error.message
else
console.log result