So it would. Definitely an icky API. I guess the preference would be to avoid changing every calling piece of code which would be a bit ugly. While that means we'll have to change exceptions we can do it slightly better like such:

    {ok, Db} = open_db(Stuff),
    try
        do stuff...
    catch
        throw:Error ->
            db_close(Db),
             throw(Error);
        error:Error ->
            db_close(Db),
            erlang:error(Error);
        exit:Error ->
            db_close(Db)
            erlang:exit(Error)
     end.