Skip to content

MySQL errors handling #9

@ghost

Description

Hello,

First of all, thanks for the library, it's really great!

I'm using sql_bridge with mysql. I noticed that the errors are only logged, and do not return for the correct treatment:

This code, from file sql_bridge_mysql_otp.erl:

query_catched(Type, DB, Q, ParamList) ->
    {Q2, ParamList2} = maybe_replace_tokens(Q, ParamList),
    ToRun = fun(Worker) ->
	    Res = mysql_query(Worker, Q2, ParamList2),
        case Res of
            {error, Reason} -> 
                error_logger:warning_msg("Error in Query.~nError: ~p~nQuery: ~s",[Reason, Q]);
            _ ->
                ok
        end,
	    case Type of
		    insert -> mysql:insert_id(Worker);
		    update -> mysql:affected_rows(Worker);
		    _ -> Res
	    end
    end,
    case sql_bridge_utils:with_poolboy_pool(DB, ToRun) of
	    {error, Reason} -> {error, Reason};
	    Result ->
            {ok, format_result(Type, Result)}
    end.

The error is just reported with a log, when ideally it would be returned to the caller. Does this have any special reason?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions