Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Sqlexpr_sqlite: better conversion error messages.

  • Loading branch information...
commit 147acca42bd1224cc6f593b883b442cab7f6bf98 1 parent dff5913
mfp authored

Showing 1 changed file with 10 additions and 9 deletions. Show diff stats Hide diff stats

  1. +10 9 sqlexpr_sqlite.ml
19 sqlexpr_sqlite.ml
@@ -183,27 +183,28 @@ struct
183 183
184 184 let failwithfmt fmt = ksprintf failwith fmt
185 185
186   - let error s =
187   - failwithfmt "Sqlexpr_sqlite error: bad data (expected %s)" s
  186 + let error s x =
  187 + failwithfmt "Sqlexpr_sqlite error: bad data (expected %s but got %s)"
  188 + s (Sqlite3.Data.to_string_debug x)
188 189
189 190 let text = function
190 191 TEXT s | BLOB s -> s
191 192 | INT n -> Int64.to_string n
192 193 | FLOAT f -> string_of_float f
193   - | _ -> error "text"
  194 + | x -> error "text" x
194 195
195   - let blob = function BLOB s | TEXT s -> s | _ -> error "blob"
  196 + let blob = function BLOB s | TEXT s -> s | x -> error "blob" x
196 197
197   - let int = function INT n -> Int64.to_int n | _ -> error "int"
198   - let int32 = function INT n -> Int64.to_int32 n | _ -> error "int"
199   - let int64 = function INT n -> n | _ -> error "int"
  198 + let int = function INT n -> Int64.to_int n | x -> error "int" x
  199 + let int32 = function INT n -> Int64.to_int32 n | x -> error "int" x
  200 + let int64 = function INT n -> n | x -> error "int" x
200 201
201   - let bool = function INT 0L -> false | INT _ -> true | _ -> error "int"
  202 + let bool = function INT 0L -> false | INT _ -> true | x -> error "int" x
202 203
203 204 let float = function
204 205 INT n -> Int64.to_float n
205 206 | FLOAT n -> n
206   - | _ -> error "float"
  207 + | x -> error "float" x
207 208
208 209 let maybe f = function
209 210 NULL -> None

0 comments on commit 147acca

Please sign in to comment.
Something went wrong with that request. Please try again.