Index: sources/device/DeviceError.cpp =================================================================== diff -u -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 -r472c10e72a8d278f13d2343f9c81c1def14490ff --- sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) +++ sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 472c10e72a8d278f13d2343f9c81c1def14490ff) @@ -31,10 +31,15 @@ QT_TR_NOOP("The device script file is not found." ), // eDevice_Scripts_Error_NotFound QT_TR_NOOP("The device script file is not executable." ), // eDevice_Scripts_Error_NotExecutable QT_TR_NOOP("The request is already in progress." ), // eDevice_Scripts_Error_IsRunning - QT_TR_NOOP("The requested value is out of range." ), // eDevice_Scripts_Error_OutOfRange - QT_TR_NOOP("The requested value is incorrect." ), // eDevice_Scripts_Error_Incorrect_Req - QT_TR_NOOP("The response value is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp + QT_TR_NOOP("The requested value length is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp_Len + QT_TR_NOOP("The requested value type is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp_Type + QT_TR_NOOP("The requested value range is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp_Range + + QT_TR_NOOP("The response value length is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp_Len + QT_TR_NOOP("The response value type is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp_Type + QT_TR_NOOP("The response value range is incorrect." ), // eDevice_Scripts_Error_Incorrect_Rsp_Range + QT_TR_NOOP("The watch file cannot be created." ), // eDevice_Watch_Error_NotCreate QT_TR_NOOP("The watch file is not found." ), // eDevice_Watch_Error_NotFound QT_TR_NOOP("The watch file cannot be added." ), // eDevice_Watch_Error_NotAdded @@ -46,6 +51,11 @@ QT_TR_NOOP("The Bluetooth cuff pair invalid address." ), // eDevice_BCuff_Error_Query_Addr QT_TR_NOOP("The Encrypted Partition error." ), // eDevice_CryptSetup_Error + QT_TR_NOOP("The Factory Reset failed." ), // eDevice_FactoryReset_Error + QT_TR_NOOP("The Decommissioning failed." ), // eDevice_Decommission_Error + QT_TR_NOOP("The Brightness failed." ), // eDevice_Brightness_Error + QT_TR_NOOP("The WiFi scan failed." ), // eDevice_WifiList_Error + QT_TR_NOOP("The USB Mount failed." ), // eDevice_USBMount_Error }; /*! @@ -70,13 +80,19 @@ QString DeviceError::deviceErrorText(DeviceError::Scripts_Error_Enum vError, int vExitCode) { QString message; int idx = vError - eDevice_Scripts_Error_Start - 1; - int len = (sizeof Scripts_Error_Text / sizeof Scripts_Error_Text[0]); - // DEBUG: qDebug() << len << idx; - if (idx >= len) { message = QObject::tr("Unknown device error %2 [%1]").arg(vExitCode).arg(vError) ; goto lOut; } + const int l = (sizeof Scripts_Error_Text / sizeof Scripts_Error_Text[0]); + const int i = eDevice_Error_End - eDevice_Scripts_Error_Start - 1; + + // DEBUG: qDebug() << l << i << idx; + // if this error happens it means not all the Error IDs in the Scripts_Error_Enum are covered in the Scripts_Error_Text + static_assert(l == i, "Device Error Scripts Error Text is incomplete."); + + if (idx >= l) { message = QObject::tr("Unknown device error %2 [%1]").arg(vExitCode).arg(vError) ; goto lOut; } if (eDevice_Scripts_Error_Start < vError && vError < eDevice_Error_End) { message = QObject::tr(Scripts_Error_Text[idx]) + (vExitCode ? QString(" [%1]").arg(vExitCode) : "") ; goto lOut; } message = QObject::tr("Device error [%1]").arg(vExitCode); + lOut: return message; }