[libcalamares] Provide accessor to error code.

- Document meaning of error codes.
 - The test-loader considers internal errors a real (test) failure,
   while errors returned normally by the modules (e.g. because the
   configuration is broken) to be ok for testing purposes.
main
Adriaan de Groot 6 years ago
parent 7149b80146
commit 1f7dfafe9a

@ -227,7 +227,8 @@ main( int argc, char* argv[] )
cError() << "Job #" << count << "failed"
<< TR( "summary", r.message() )
<< TR( "details", r.details() );
++failure_count;
if ( r.errorCode() > 0 )
++failure_count;
}
++count;
}

@ -71,7 +71,7 @@ JobResult::ok()
JobResult
JobResult::error( const QString& message, const QString& details )
{
return JobResult( message, details, -1 );
return JobResult( message, details, GenericError );
}
JobResult

@ -29,6 +29,13 @@ namespace Calamares {
class DLLEXPORT JobResult
{
public:
/** @brief Distinguish classes of errors
*
* All "ok result" have errorCode 0 (NoError).
* Errors returned from job execution have values < 0.
* Errors before job execution, or not returned by the job execution
* itself, have values > 0.
*/
enum
{
NoError = 0,
@ -49,6 +56,8 @@ public:
virtual QString details() const;
virtual void setDetails( const QString& details );
int errorCode() const { return m_number; }
/// @brief an "ok status" result
static JobResult ok();
/// @brief an "error" result resulting from the execution of the job

Loading…
Cancel
Save