Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
5161414c
Commit
5161414c
authored
Nov 01, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error report on open failure.
parent
85d5a1c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
sqlite.go
sqlite.go
+22
-1
No files found.
sqlite.go
View file @
5161414c
...
...
@@ -29,6 +29,21 @@ import (
"unsafe"
)
// OpenError is for detailed report on SQLite open failure.
type
OpenError
struct
{
Code
Errno
// thread safe error code
ExtendedCode
int
Msg
string
Filename
string
}
func
(
e
OpenError
)
Error
()
string
{
if
len
(
e
.
Msg
)
>
0
{
return
fmt
.
Sprintf
(
"%s (%s)"
,
e
.
Msg
,
e
.
Code
.
Error
())
}
return
e
.
Code
.
Error
()
}
// ConnError is a wrapper for all SQLite connection related error.
type
ConnError
struct
{
c
*
Conn
...
...
@@ -232,8 +247,14 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error)
}
rv
:=
C
.
sqlite3_open_v2
(
cname
,
&
db
,
C
.
int
(
openFlags
),
vfs
)
if
rv
!=
C
.
SQLITE_OK
{
if
db
!=
nil
{
if
db
!=
nil
{
// try to extract futher details from db...
err
:=
OpenError
{
Code
:
Errno
(
rv
),
ExtendedCode
:
int
(
C
.
sqlite3_extended_errcode
(
db
)),
Msg
:
C
.
GoString
(
C
.
sqlite3_errmsg
(
db
)),
Filename
:
filename
,
}
C
.
sqlite3_close
(
db
)
return
nil
,
err
}
return
nil
,
Errno
(
rv
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment