Skip to content

Commit 4c814f4

Browse files
committed
Corrected error propagation.
1 parent 84e22c9 commit 4c814f4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

crt/aws-c-iot

devicedefender/source/DeviceDefender.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ namespace Aws
5555
aws_iotdevice_defender_config_set_task_period_ns(m_taskConfig,
5656
aws_timestamp_convert(taskPeriodSeconds, AWS_TIMESTAMP_SECS, AWS_TIMESTAMP_NANOS, NULL));
5757
}
58+
else
59+
{
60+
m_lastError = aws_last_error();
61+
}
5862
}
5963

6064
ReportTask::ReportTask(ReportTask &&toMove) noexcept
@@ -100,13 +104,11 @@ namespace Aws
100104

101105
int ReportTask::StartTask() noexcept
102106
{
103-
if (m_taskConfig != nullptr && (this->GetStatus() == ReportTaskStatus::Ready || this->GetStatus() == ReportTaskStatus::Stopped))
107+
if (m_taskConfig != nullptr && !m_lastError && (this->GetStatus() == ReportTaskStatus::Ready || this->GetStatus() == ReportTaskStatus::Stopped))
104108
{
105-
m_lastError = aws_iotdevice_defender_task_create(&m_owningTask, this->m_taskConfig,
109+
if (AWS_OP_SUCCESS != aws_iotdevice_defender_task_create(&m_owningTask, this->m_taskConfig,
106110
m_mqttConnection->GetUnderlyingConnection(),
107-
aws_event_loop_group_get_next_loop(m_eventLoopGroup.GetUnderlyingHandle()));
108-
109-
if (this->m_owningTask == nullptr)
111+
aws_event_loop_group_get_next_loop(m_eventLoopGroup.GetUnderlyingHandle())))
110112
{
111113
this->m_lastError = aws_last_error();
112114
aws_raise_error(this->m_lastError);

0 commit comments

Comments
 (0)