Skip to content

Commit

Permalink
More detailed error logging in sanecpp
Browse files Browse the repository at this point in the history
  • Loading branch information
SimulPiscator committed Feb 7, 2024
1 parent 025da58 commit a6db8c3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sanecpp/sanecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,11 @@ option::string_value(int index) const
SANE_Handle h = m_set ? m_set->m_device.get() : nullptr;
if (h && is_string() && index == 0) {
std::vector<SANE_Char> value(m_desc->size);
if (SANE_STATUS_GOOD ==
::sane_control_option(
h, m_index, SANE_ACTION_GET_VALUE, value.data(), nullptr))
SANE_Status status = ::sane_control_option(h, m_index, SANE_ACTION_GET_VALUE, value.data(), nullptr);
if (status == SANE_STATUS_GOOD)
s = value.data();
else
log << "sane_control_option(" << h << ", " << m_index << ", SANE_ACTION_GET_VALUE) -> " << status << std::endl;
}
return s;
}
Expand Down Expand Up @@ -389,10 +390,11 @@ option::numeric_value(int index) const
if (index < 0 || index >= array_size())
return value;
std::vector<SANE_Word> data(array_size());
if (SANE_STATUS_GOOD !=
::sane_control_option(
h, m_index, SANE_ACTION_GET_VALUE, data.data(), nullptr))
SANE_Status status = ::sane_control_option(h, m_index, SANE_ACTION_GET_VALUE, data.data(), nullptr);
if (status != SANE_STATUS_GOOD) {
log << "sane_control_option(" << h << ", " << m_index << ", SANE_ACTION_GET_VALUE) -> " << status << std::endl;
return value;
}
value = data[index];
if (m_desc->type == SANE_TYPE_FIXED)
value = SANE_UNFIX(value);
Expand Down

0 comments on commit a6db8c3

Please sign in to comment.