Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
7f533666
Unverified
Commit
7f533666
authored
Nov 08, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error reporting
parent
e44539ef
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
19 deletions
+37
-19
src/category.cpp
+21
-19
src/file.cpp
+8
-0
src/pdb/pdb2cif.cpp
+8
-0
No files found.
src/category.cpp
View file @
7f533666
...
@@ -746,6 +746,8 @@ void category::set_validator(const validator *v, datablock &db)
...
@@ -746,6 +746,8 @@ void category::set_validator(const validator *v, datablock &db)
{
{
std
::
set
<
std
::
string
>
missing
;
std
::
set
<
std
::
string
>
missing
;
if
(
not
empty
())
{
std
::
vector
<
uint16_t
>
kix
;
std
::
vector
<
uint16_t
>
kix
;
for
(
auto
k
:
m_cat_validator
->
m_keys
)
for
(
auto
k
:
m_cat_validator
->
m_keys
)
{
{
...
@@ -753,27 +755,13 @@ void category::set_validator(const validator *v, datablock &db)
...
@@ -753,27 +755,13 @@ void category::set_validator(const validator *v, datablock &db)
if
(
kix
.
back
()
>=
m_columns
.
size
())
if
(
kix
.
back
()
>=
m_columns
.
size
())
missing
.
insert
(
k
);
missing
.
insert
(
k
);
}
}
}
// TODO: perhaps reintroduce the following check?
if
(
missing
.
empty
())
// if (missing.empty())
// {
// // First check if all records do have their mandatory fields
// for (auto r : *this)
// {
// for (auto ix : kix)
// {
// if (r[ix].empty())
// missing.insert(m_columns[ix].m_name);
// }
// }
// }
if
(
missing
.
size
()
==
1
)
throw
std
::
runtime_error
(
"Cannot construct index since the key field "
+
*
missing
.
begin
()
+
" in "
+
m_name
+
" is empty"
);
if
(
not
missing
.
empty
())
throw
std
::
runtime_error
(
"Cannot construct index since the key fields "
+
cif
::
join
(
missing
,
", "
)
+
" in "
+
m_name
+
" are empty"
);
m_index
=
new
category_index
(
this
);
m_index
=
new
category_index
(
this
);
else
if
(
VERBOSE
>
0
)
std
::
cerr
<<
"Cannot construct index since the key field"
<<
(
missing
.
size
()
>
1
?
"s"
:
""
)
<<
" "
<<
cif
::
join
(
missing
,
", "
)
+
" in "
+
m_name
+
" "
+
(
missing
.
size
()
==
1
?
"is"
:
"are"
)
<<
" missing"
<<
std
::
endl
;
}
}
}
}
else
else
...
@@ -854,6 +842,20 @@ bool category::is_valid() const
...
@@ -854,6 +842,20 @@ bool category::is_valid() const
result
=
false
;
result
=
false
;
}
}
if
(
m_cat_validator
->
m_keys
.
empty
()
==
false
and
m_index
==
nullptr
)
{
std
::
set
<
std
::
string
>
missing
;
for
(
auto
k
:
m_cat_validator
->
m_keys
)
{
if
(
get_column_ix
(
k
)
>=
m_columns
.
size
())
missing
.
insert
(
k
);
}
m_validator
->
report_error
(
"In category "
+
m_name
+
" the index is missing, likely due to missing key fields: "
+
join
(
missing
,
", "
),
false
);
result
=
false
;
}
#if not defined(NDEBUG)
#if not defined(NDEBUG)
// check index?
// check index?
if
(
m_index
)
if
(
m_index
)
...
...
src/file.cpp
View file @
7f533666
...
@@ -183,10 +183,18 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name)
...
@@ -183,10 +183,18 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name)
void
file
::
load
(
const
std
::
filesystem
::
path
&
p
)
void
file
::
load
(
const
std
::
filesystem
::
path
&
p
)
{
{
try
{
gxrio
::
ifstream
in
(
p
);
gxrio
::
ifstream
in
(
p
);
if
(
not
in
.
is_open
())
if
(
not
in
.
is_open
())
throw
std
::
runtime_error
(
"Could not open file "
+
p
.
string
());
throw
std
::
runtime_error
(
"Could not open file "
+
p
.
string
());
load
(
in
);
load
(
in
);
}
catch
(
const
std
::
exception
&
ex
)
{
throw_with_nested
(
std
::
runtime_error
(
"Error reading file "
+
p
.
string
()));
}
}
}
void
file
::
load
(
std
::
istream
&
is
)
void
file
::
load
(
std
::
istream
&
is
)
...
...
src/pdb/pdb2cif.cpp
View file @
7f533666
...
@@ -6223,11 +6223,18 @@ file read(std::istream &is)
...
@@ -6223,11 +6223,18 @@ file read(std::istream &is)
file
read
(
const
std
::
filesystem
::
path
&
file
)
file
read
(
const
std
::
filesystem
::
path
&
file
)
{
{
try
{
gxrio
::
ifstream
in
(
file
);
gxrio
::
ifstream
in
(
file
);
if
(
not
in
.
is_open
())
if
(
not
in
.
is_open
())
throw
std
::
runtime_error
(
"Could not open file "
+
file
.
string
()
+
" for input"
);
throw
std
::
runtime_error
(
"Could not open file "
+
file
.
string
()
+
" for input"
);
return
read
(
in
);
return
read
(
in
);
}
catch
(
const
std
::
exception
&
ex
)
{
throw_with_nested
(
std
::
runtime_error
(
"Error reading file "
+
file
.
string
()));
}
}
}
}
//
namespace
pdbx
}
//
namespace
pdbx
\ No newline at end of file
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