Skip to content

Commit

Permalink
dub.json sourcePath adjustment, mysql fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cruisercoder committed Apr 27, 2016
1 parent ac8790a commit f627b81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"copyright": "Copyright © 2015, Erik Smith",
"authors": ["Erik Smith"],
"license": "MIT",
"sourcePaths": [".", "src"],
"sourcePaths": ["src"]
}

17 changes: 11 additions & 6 deletions src/std/database/mysql/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static bool isError()(int ret) {

private static T* check(T)(string msg, T* ptr) {
info(msg);
if (!ptr) throw new DatabaseException("mysql error: " ~ msg);
if (!ptr) createError(msg);
return ptr;
}

Expand All @@ -63,12 +63,17 @@ private static int check()(string msg, MYSQL_STMT* stmt, int ret) {
return ret;
}

private static void createError()(string msg) {
throw new DatabaseException("mysql error: " ~ msg);
}

private static void createError()(string msg, int ret) {
throw new DatabaseException("mysql error: status: " ~ to!string(ret) ~ ":" ~ msg);
}

private static void createError()(string msg, MYSQL_STMT* stmt, int ret) {
info(msg, ":", ret);
if (!isError(ret)) return;
import core.stdc.string: strlen;
const(char*) err = mysql_stmt_error(stmt);
//info("error: ", err[0..strlen(err)]); //fix
throw new DatabaseException("mysql error: " ~ msg);
}

Expand Down Expand Up @@ -368,10 +373,10 @@ struct Impl(Policy) {
//rows_ = row_count_;
return false;
} else if (status == MYSQL_DATA_TRUNCATED) {
throw new DatabaseException("fetch: database truncation");
createError("mysql_stmt_fetch: truncation", status);
}

createError("mysql_stmt_fetch",stmt.stmt,status);
createError("mysql_stmt_fetch", stmt.stmt, status);
return false;
}

Expand Down

0 comments on commit f627b81

Please sign in to comment.