Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
5335116a
Commit
5335116a
authored
1 year ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Use string concatenation in exception messages
parent
7002255c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/List.h
+24
-34
24 additions, 34 deletions
src/include/List.h
src/libnptm/Configuration.cpp
+2
-2
2 additions, 2 deletions
src/libnptm/Configuration.cpp
with
26 additions
and
36 deletions
src/include/List.h
+
24
−
34
View file @
5335116a
...
@@ -12,12 +12,8 @@
...
@@ -12,12 +12,8 @@
*/
*/
class
ListOutOfBoundsException
:
public
std
::
exception
{
class
ListOutOfBoundsException
:
public
std
::
exception
{
protected:
protected:
//! \brief Minimum index defined in the List.
//! Description of the problem.
int
min_index
;
std
::
string
message
;
//! \brief Maximum index defined in the List.
int
max_index
;
//! \brief List index requested by user.
int
requested_index
;
public:
public:
/**
/**
...
@@ -28,21 +24,15 @@ public:
...
@@ -28,21 +24,15 @@ public:
* \param max: `int` The maximum index allowed by the list.
* \param max: `int` The maximum index allowed by the list.
*/
*/
ListOutOfBoundsException
(
int
requested
,
int
min
,
int
max
)
{
ListOutOfBoundsException
(
int
requested
,
int
min
,
int
max
)
{
min_index
=
min
;
message
=
"Error: requested index "
+
std
::
to_string
(
requested
)
max_index
=
max
;
+
" out of list allowed bounds ["
+
std
::
to_string
(
min
)
+
", "
requested_index
=
requested
;
+
std
::
to_string
(
max
-
1
)
+
"]"
;
}
}
/**
/**
* \brief Exception message.
* \brief Exception message.
*/
*/
virtual
const
char
*
what
()
const
throw
()
{
virtual
const
char
*
what
()
const
throw
()
{
std
::
string
message
=
"Error: requested index "
;
message
+=
requested_index
;
message
+=
" is out of range ["
;
message
+=
min_index
;
message
+=
", "
;
message
+=
(
max_index
-
1
);
message
+=
"]"
;
return
message
.
c_str
();
return
message
.
c_str
();
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
src/libnptm/Configuration.cpp
+
2
−
2
View file @
5335116a
...
@@ -265,7 +265,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
...
@@ -265,7 +265,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
try
{
try
{
xi_vec
=
new
double
[
nxi
]();
xi_vec
=
new
double
[
nxi
]();
}
catch
(
const
bad_alloc
&
ex
)
{
}
catch
(
const
bad_alloc
&
ex
)
{
throw
UnrecognizedConfigurationException
(
"Wrong parameter set: invalid number of scales "
+
nxi
);
throw
UnrecognizedConfigurationException
(
"Wrong parameter set: invalid number of scales "
+
to_string
(
nxi
)
)
;
}
}
for
(
int
i
=
0
;
i
<
nxi
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nxi
;
i
++
)
{
input
.
read
(
reinterpret_cast
<
char
*>
(
&
(
xi_vec
[
i
])),
sizeof
(
double
));
input
.
read
(
reinterpret_cast
<
char
*>
(
&
(
xi_vec
[
i
])),
sizeof
(
double
));
...
@@ -285,7 +285,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
...
@@ -285,7 +285,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
try
{
try
{
rcf_vector
[
i115
-
1
]
=
new
double
[
nsh
]();
rcf_vector
[
i115
-
1
]
=
new
double
[
nsh
]();
}
catch
(
const
bad_alloc
&
ex
)
{
}
catch
(
const
bad_alloc
&
ex
)
{
throw
UnrecognizedConfigurationException
(
"Wrong parameter set: invalid number of layers "
+
nsh
);
throw
UnrecognizedConfigurationException
(
"Wrong parameter set: invalid number of layers "
+
to_string
(
nsh
)
)
;
}
}
for
(
int
nsi
=
0
;
nsi
<
nsh
;
nsi
++
)
{
for
(
int
nsi
=
0
;
nsi
<
nsh
;
nsi
++
)
{
input
.
read
(
reinterpret_cast
<
char
*>
(
&
(
rcf_vector
[
i115
-
1
][
nsi
])),
sizeof
(
double
));
input
.
read
(
reinterpret_cast
<
char
*>
(
&
(
rcf_vector
[
i115
-
1
][
nsi
])),
sizeof
(
double
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment