aboutsummaryrefslogtreecommitdiffstats
path: root/c_src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2012-02-09 16:02:41 -0500
committerBrian Cully <bjc@kublai.com>2012-02-09 16:02:41 -0500
commit3f739d918f99f0324b9b8ad9ea9c7bd5888c46f7 (patch)
tree21801e8e8bcf7f45a52bbf1509c4f07441c45251 /c_src
parentb9892e56efff45f76d505337fc03f3e04f7c6073 (diff)
downloadmysqlerl-3f739d918f99f0324b9b8ad9ea9c7bd5888c46f7.tar.gz
mysqlerl-3f739d918f99f0324b9b8ad9ea9c7bd5888c46f7.zip
Return errors when connecting fails.
Diffstat (limited to 'c_src')
-rw-r--r--c_src/mysqlerl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/c_src/mysqlerl.c b/c_src/mysqlerl.c
index 5c67517..37be2e4 100644
--- a/c_src/mysqlerl.c
+++ b/c_src/mysqlerl.c
@@ -248,8 +248,10 @@ handle_connect(ETERM *msg)
logmsg("INFO: Connecting to %s on %s:%d as %s", db_name, host, port, user);
if (mysql_real_connect(&dbh, host, user, passwd,
db_name, port, NULL, 0) == NULL) {
- logmsg("ERROR: Failed to connect to database %s as %s: %s.",
- db_name, user, mysql_error(&dbh));
+ resp = erl_format("{error, {mysql_error, ~i, ~s}}",
+ mysql_errno(&dbh), mysql_error(&dbh));
+ write_msg(resp);
+ erl_free_term(resp);
exit(2);
}