Index: sources/device/DeviceError.cpp =================================================================== diff -u -r9ae3b0d6624904693329309aaf8ff02784c17184 -r47c8f13876317ba36500400f894d96c9bce9eb17 --- sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 9ae3b0d6624904693329309aaf8ff02784c17184) +++ sources/device/DeviceError.cpp (.../DeviceError.cpp) (revision 47c8f13876317ba36500400f894d96c9bce9eb17) @@ -27,13 +27,22 @@ using namespace Device; const char *DeviceError::Scripts_Error_Text[] = { - QT_TR_NOOP("The device script file is not found."), - QT_TR_NOOP("The device script file is not executable."), - QT_TR_NOOP("The request is already in progress."), - QT_TR_NOOP("The requested value is out of range."), - QT_TR_NOOP("The requested value is incorrect."), - QT_TR_NOOP("The response value is incorrect."), - QT_TR_NOOP("The watch file is not found."), + QT_TR_NOOP("The device script abnormal exit." ), // eDevice_Scripts_Error_Status + 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 watch file is not found." ), // eDevice_Watch_Error_NotFound + QT_TR_NOOP("The watch file cannot be added." ), // eDevice_Watch_Error_NotAdded + + QT_TR_NOOP("The Bluetooth cuff pair clear error." ), // eDevice_BCuff_Error_Reset + + QT_TR_NOOP("The Bluetooth cuff pair query error." ), // eDevice_BCuff_Error_Query + QT_TR_NOOP("The Bluetooth cuff pair query empty." ), // eDevice_BCuff_Error_Query_Empty + QT_TR_NOOP("The Bluetooth cuff pair invalid address." ), // eDevice_BCuff_Error_Query_Addr }; /*! @@ -49,21 +58,22 @@ DeviceError::Scripts_Error_Enum err = DeviceError::eDevice_OK; vScript = _scriptsFolder + vShellScript; QFileInfo info(vScript); - if ( ! info.exists () ) { err = DeviceError::eDevice_Scripts_Error_NotFound ; goto lOut; } - if ( ! info.isExecutable() ) { err = DeviceError::eDevice_Scripts_Error_NotExecutable ; goto lOut; } + if ( ! info.exists () ) { err = DeviceError::eDevice_Scripts_Error_NotFound ; goto lOut; } + if ( ! info.isExecutable() ) { err = DeviceError::eDevice_Scripts_Error_NotExecutable ; goto lOut; } lOut: return err; } -QString DeviceError::deviceErrorText(DeviceError::Scripts_Error_Enum vError) { +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]; - if (idx > len) { message = QObject::tr("Device error no text defined [%1]").arg(vError); goto lOut; } + int len = (sizeof Scripts_Error_Text / sizeof Scripts_Error_Text[0]); + qDebug() << len << idx; + if (idx >= len) { 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]); goto lOut; } + message = QObject::tr(Scripts_Error_Text[idx]) + (vExitCode ? QString(" [%1]").arg(vExitCode) : ""); goto lOut; } - message = QObject::tr("Device error"); + message = QObject::tr("Device error [%1]").arg(vExitCode); lOut: return message; }