Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scdaq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scouting-demonstrator
scdaq
Commits
79c1c4ad
Commit
79c1c4ad
authored
1 year ago
by
Giovanna Lazzari Miotto
Browse files
Options
Downloads
Patches
Plain Diff
doc: config: Improve comments, logging, exceptions
parent
43f71a5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!86
refactor: config: Overhaul `Config` interface
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/config.cc
+21
-15
21 additions, 15 deletions
src/config.cc
src/config.h
+11
-9
11 additions, 9 deletions
src/config.h
with
32 additions
and
24 deletions
src/config.cc
+
21
−
15
View file @
79c1c4ad
...
...
@@ -21,12 +21,14 @@ uint32_t ConfigMap::Get<uint32_t>(const std::string &k) {
ValueType
value
=
at
(
k
);
try
{
return
value
.
asUInt
();
}
catch
(
std
::
exception
&
e
)
{
LOG
(
DEBUG
)
<<
"Value '"
<<
value
.
asString
()
<<
"' not natively convertible to uint32"
;
}
catch
(
std
::
exception
&
e1
)
{
const
auto
str_val
=
value
.
asString
();
LOG
(
DEBUG
)
<<
"Key: "
<<
k
<<
"| Value '"
<<
str_val
<<
"' | Exception: "
<<
e1
.
what
();
LOG
(
DEBUG
)
<<
"Recovering by converting to uint32_t"
;
try
{
return
static_cast
<
uint32_t
>
(
std
::
stoul
(
value
.
asString
()
));
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"Con
figuration error with key
:
'
"
<<
k
<<
"'"
;
return
static_cast
<
uint32_t
>
(
std
::
stoul
(
str_val
));
}
catch
(
std
::
exception
&
e
2
)
{
LOG
(
ERROR
)
<<
"Con
version of '"
<<
str_val
<<
"' failed with exception
: "
<<
e2
.
what
()
;
throw
;
}
}
...
...
@@ -37,12 +39,14 @@ uint64_t ConfigMap::Get<uint64_t>(const std::string &k) {
ValueType
value
=
at
(
k
);
try
{
return
value
.
asUInt64
();
}
catch
(
std
::
exception
&
e
)
{
LOG
(
DEBUG
)
<<
"Value '"
<<
value
.
asString
()
<<
"' not natively convertible to uint64"
;
}
catch
(
std
::
exception
&
e1
)
{
const
auto
str_val
=
value
.
asString
();
LOG
(
DEBUG
)
<<
"Key: "
<<
k
<<
"| Value '"
<<
str_val
<<
"' | Exception: "
<<
e1
.
what
();
LOG
(
DEBUG
)
<<
"Recovering by converting to uint64_t"
;
try
{
return
static_cast
<
uint64_t
>
(
std
::
stoul
(
value
.
asString
()
));
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"Con
figuration error with key
:
'
"
<<
k
<<
"'"
;
return
static_cast
<
uint64_t
>
(
std
::
stoul
(
str_val
));
}
catch
(
std
::
exception
&
e
2
)
{
LOG
(
ERROR
)
<<
"Con
version of '"
<<
str_val
<<
"' failed with exception
: "
<<
e2
.
what
()
;
throw
;
}
}
...
...
@@ -53,12 +57,14 @@ int ConfigMap::Get<int>(const std::string &k) {
ValueType
value
=
at
(
k
);
try
{
return
value
.
asInt
();
}
catch
(
std
::
exception
&
e
)
{
LOG
(
DEBUG
)
<<
"Value '"
<<
value
.
asString
()
<<
"' not natively convertible to integer"
;
}
catch
(
std
::
exception
&
e1
)
{
const
auto
str_val
=
value
.
asString
();
LOG
(
DEBUG
)
<<
"Key: "
<<
k
<<
"| Value '"
<<
str_val
<<
"' | Exception: "
<<
e1
.
what
();
LOG
(
DEBUG
)
<<
"Recovering by converting to int"
;
try
{
return
st
d
::
stoi
(
value
.
asString
(
));
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"Con
figuration error with key
:
'
"
<<
k
<<
"'"
;
return
st
atic_cast
<
int
>
(
std
::
stoul
(
str_val
));
}
catch
(
std
::
exception
&
e
2
)
{
LOG
(
ERROR
)
<<
"Con
version of '"
<<
str_val
<<
"' failed with exception
: "
<<
e2
.
what
()
;
throw
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/config.h
+
11
−
9
View file @
79c1c4ad
...
...
@@ -146,22 +146,24 @@ class Config {
}
inline
uint32_t
GetSourceID
(
ProcessorType
processor
)
const
{
// Source ID is only used to fill the output CMSSW FRD event header, which is currently
// supported for the GMT and Calo processors.
switch
(
processor
)
{
case
ProcessorType
::
GMT
:
return
1
;
case
ProcessorType
::
CALO
:
return
2
;
default:
if
(
support_cmssw_headers_
)
{
LOG
(
ERROR
)
<<
"PROCESSOR_TYPE INCOMPATIBLE WITH CMSSW HEADER OUTPUT OPTION, PLEASE DISABLE "
"CMSSW HEADERS OR CHANGE PROCESSOR_TYPE, EXITING"
;
throw
std
::
invalid_argument
(
"ERROR: PROCESSOR_TYPE INCOMPATIBLE WITH CMSSW HEADER OUTPUT OPTION, PLEASE DISABLE "
"CMSSW HEADERS OR CHANGE PROCESSOR_TYPE"
);
}
else
{
LOG
(
WARNING
)
<<
"Undefined source ID has been requested: returning 0."
;
if
(
!
support_cmssw_headers_
)
{
LOG
(
WARNING
)
<<
"Specified `processor_type` has no pre-defined source ID. Using `source_id`=0."
;
return
0
;
}
else
{
const
char
msg_incompatible
[]
=
"Specified `processor_type` incompatible with CMSSW header-enabled outputs. Disable "
"`cmsswHeaders` or change `processor_type` to one of {GMT, CALO}."
;
LOG
(
ERROR
)
<<
msg_incompatible
;
throw
std
::
invalid_argument
(
msg_incompatible
);
}
}
}
...
...
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