[rabbitmq-discuss] trying to figure out erlando
Matthew Sackman
matthew at rabbitmq.com
Mon May 23 17:51:23 BST 2011
Hi Jon,
I'm afraid most of my replies on this thread have been riddled with
errors one way or another.
Firstly, error_t strips of the {ok, ...} in bind. So you should be
writing "X <- foo()" rather than "{ok, X} <- foo()".
Secondly, you are right - it should be ErrorT:run(M), not error_t:run(M)
(I'm rapidly losing any enthusiasm for parameterised modules...).
Thirdly, if your function just returns 'ok' then you're in trouble as
each and every function must return something of the form {ok, X} or
{error, X}. So the amqp_channel:close(Chan) becomes a problem. About the
only way around is to change that to:
case amqp_channel:close(Chan) of
ok -> return(ok);
Err -> fail(Err)
end
Fourthly (slight repeat of 1st point), don't match {ok, X} against a
return - again, the {ok,..} gets stripped.
So, in summary, I think you want:
ErrorT = error_t:new(identity_m),
M = do([ErrorT ||
Chan <- amqp_connection:open_channel(AMQP),
Resp <- return(Publish(Channel)),
case amqp_channel:close(Channel) of
ok -> return(ok);
{error, Err} -> fail(Err)
end,
Resp]),
ErrorT:run(M).
I *think* that should work!
Matthew
More information about the rabbitmq-discuss
mailing list