Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
73e75532
Commit
73e75532
authored
Nov 12, 2015
by
Hugo Beauzée-Luyssen
Browse files
sqlite: Move errors in their own header
parent
ffe3ba7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/database/SqliteErrors.h
0 → 100644
View file @
73e75532
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#pragma once
#include
<string>
#include
<exception>
namespace
sqlite
{
namespace
errors
{
class
ConstraintViolation
:
public
std
::
exception
{
public:
ConstraintViolation
(
const
std
::
string
&
req
,
const
std
::
string
&
err
)
{
m_reason
=
std
::
string
(
"Request <"
)
+
req
+
"> aborted due to "
"constraint violation ("
+
err
+
")"
;
}
virtual
const
char
*
what
()
const
noexcept
override
{
return
m_reason
.
c_str
();
}
private:
std
::
string
m_reason
;
};
class
ColumnOutOfRange
:
public
std
::
exception
{
public:
ColumnOutOfRange
(
unsigned
int
idx
,
unsigned
int
nbColumns
)
{
m_reason
=
"Attempting to extract column at index "
+
std
::
to_string
(
idx
)
+
" from a request with "
+
std
::
to_string
(
nbColumns
)
+
"columns"
;
}
virtual
const
char
*
what
()
const
noexcept
override
{
return
m_reason
.
c_str
();
}
private:
std
::
string
m_reason
;
};
}
// namespace errors
}
// namespace sqlite
src/database/SqliteTools.h
View file @
73e75532
...
...
@@ -34,6 +34,7 @@
#include
"Types.h"
#include
"database/SqliteConnection.h"
#include
"database/SqliteErrors.h"
#include
"logging/Logger.h"
namespace
sqlite
...
...
@@ -141,44 +142,6 @@ struct Traits<T, typename std::enable_if<IsSameDecay<T, int64_t>::value>::type>
(
*
Load
)(
sqlite3_stmt
*
,
int
)
=
&
sqlite3_column_int64
;
};
namespace
errors
{
class
ConstraintViolation
:
public
std
::
exception
{
public:
ConstraintViolation
(
const
std
::
string
&
req
,
const
std
::
string
&
err
)
{
m_reason
=
std
::
string
(
"Request <"
)
+
req
+
"> aborted due to "
"constraint violation ("
+
err
+
")"
;
}
virtual
const
char
*
what
()
const
noexcept
override
{
return
m_reason
.
c_str
();
}
private:
std
::
string
m_reason
;
};
class
ColumnOutOfRange
:
public
std
::
exception
{
public:
ColumnOutOfRange
(
unsigned
int
idx
,
unsigned
int
nbColumns
)
{
m_reason
=
"Attempting to extract column at index "
+
std
::
to_string
(
idx
)
+
" from a request with "
+
std
::
to_string
(
nbColumns
)
+
"columns"
;
}
virtual
const
char
*
what
()
const
noexcept
override
{
return
m_reason
.
c_str
();
}
private:
std
::
string
m_reason
;
};
}
class
Row
{
public:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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