<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>For my current project, I will never attempt to recover from an error, and just want to fail reporting the error.</div><div><br></div><div>Most io function return an io.res, or something closely related, which needs checking instead of throwing an exception.   And I get a LOT of repetitive, error handling code cluttering up my predicate bodies.<br></div><div><br></div><div>Is there some way I can box those functions up to throw an exception on error, instead?   Most of my code looks a lot like:</div><div><br></div><div><span style="font-family:monospace,monospace">remove_file_recursively(Path, !IO) :-<br>  io.remove_file_recursively(Path, Res, !IO),<br>  (<br>    Res = ok<br>  ;<br>    Res = error(Error),<br>    io.error_message(Error, ErrorString),    <br>    string.format("Could not recursively remove %s: %s", [s(Path), s(ErrorString)], ExceptionMessage),<br>    exception.throw(ExceptionMessage)<br>  ).<br></span><br></div><div>With only minor variations for the position of Res in the io function call, and the actual Result type (io.res, io.res(T), io.result, etc.....).   So it SEEMS like it might be possible to write a predicate like:  <span style="font-family:monospace,monospace">io_det(io.remove_file_recursively, Path, !IO)</span><br></div></div></div></div>