@@ -179,7 +179,7 @@ struct StatementImpl(T) {
179179 cast (int ) sql.length + 1 ,
180180 &st,
181181 null );
182- if (res != SQLITE_OK ) error( " prepare" , res);
182+ if (res != SQLITE_OK ) throw_error(sq, " prepare" , res);
183183 binds_ = sqlite3_bind_parameter_count(st);
184184 }
185185 }
@@ -194,7 +194,9 @@ struct StatementImpl(T) {
194194 hasRows = true ;
195195 } else if (status == SQLITE_DONE ) {
196196 reset();
197- } else throw new DatabaseException (" step error" );
197+ } else {
198+ throw_error(sq, " step error" , status);
199+ }
198200 }
199201
200202 void query (X... ) (X args) {
@@ -212,8 +214,6 @@ struct StatementImpl(T) {
212214 if (status != SQLITE_OK ) throw new DatabaseException (" sqlite3_reset error" );
213215 }
214216
215- void error (string msg, int ret) {con.error(msg, ret);}
216-
217217}
218218
219219struct Bind (T) {
@@ -222,8 +222,6 @@ struct Bind(T) {
222222}
223223
224224struct ResultImpl (T) {
225- // alias ResultRange = .ResultRange!T;
226- // alias Row = .Row!T;
227225 alias Statement = .StatementImpl! T;
228226 alias Bind = .Bind! T;
229227 alias Allocator = T.Allocator;
@@ -283,10 +281,10 @@ struct ResultImpl(T) {
283281}
284282
285283void throw_error ()(sqlite3 * sq, string msg, int ret) {
284+ import std.conv ;
286285 import core.stdc.string : strlen;
287286 const (char * ) err = sqlite3_errmsg(sq);
288- info(msg, " :" , err[0 .. strlen(err)]);
289- throw new DatabaseException (" sqlite error: " ~ msg ~ " : " ); // need to send err
287+ throw new DatabaseException (" sqlite error: " ~ msg ~ " : " ~ to! string (err)); // need to send err
290288}
291289
292290void throw_error ()(string label) {
@@ -306,17 +304,17 @@ void throw_error()(string label, char *msg) {
306304
307305/*
308306
309- auto as(T:string)() {
310- import core.stdc.string: strlen;
311- auto ptr = cast(immutable char*) sqlite3_column_text(result_.st_, cast(int) idx_);
312- return cast(string) ptr[0..strlen(ptr)]; // fix with length
313- }
307+ auto as(T:string)() {
308+ import core.stdc.string: strlen;
309+ auto ptr = cast(immutable char*) sqlite3_column_text(result_.st_, cast(int) idx_);
310+ return cast(string) ptr[0..strlen(ptr)]; // fix with length
311+ }
314312
315- auto chars() {
316- import core.stdc.string: strlen;
317- auto data = sqlite3_column_text(result_.st_, cast(int) idx_);
318- return data ? data[0 .. strlen(data)] : data[0..0];
319- }
313+ auto chars() {
314+ import core.stdc.string: strlen;
315+ auto data = sqlite3_column_text(result_.st_, cast(int) idx_);
316+ return data ? data[0 .. strlen(data)] : data[0..0];
317+ }
320318
321319// char*, string_ref?
322320
@@ -325,7 +323,7 @@ const(char*) toStringz() {
325323return sqlite3_column_text(result_.st_, cast(int) idx_);
326324}
327325
328- */
326+ */
329327
330328extern (C ) int sqlite_callback(void * cb, int howmany, char ** text, char ** columns) {
331329 return 0 ;
0 commit comments