mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-25 08:28:22 -04:00
[libcalamares] Refactor explanation of process-job errors
This commit is contained in:
parent
c6ab4195c7
commit
f8a53f9646
2 changed files with 41 additions and 31 deletions
|
@ -82,37 +82,7 @@ ProcessJob::exec()
|
||||||
QString(),
|
QString(),
|
||||||
m_timeoutSec );
|
m_timeoutSec );
|
||||||
|
|
||||||
if ( ec == 0 )
|
return explainProcess( ec, m_command, output, m_timeoutSec );
|
||||||
return JobResult::ok();
|
|
||||||
|
|
||||||
if ( ec == -1 ) //Crash!
|
|
||||||
return JobResult::error( tr( "External command crashed" ),
|
|
||||||
tr( "Command %1 crashed.\nOutput:\n%2" )
|
|
||||||
.arg( m_command )
|
|
||||||
.arg( output ) );
|
|
||||||
|
|
||||||
if ( ec == -2 )
|
|
||||||
return JobResult::error( tr( "External command failed to start" ),
|
|
||||||
tr( "Command %1 failed to start." )
|
|
||||||
.arg( m_command ) );
|
|
||||||
|
|
||||||
if ( ec == -3 )
|
|
||||||
return JobResult::error( tr( "Internal error when starting command" ),
|
|
||||||
tr( "Bad parameters for process job call." ) );
|
|
||||||
|
|
||||||
if ( ec == -4 )
|
|
||||||
return JobResult::error( tr( "External command failed to finish" ),
|
|
||||||
tr( "Command %1 failed to finish in %2s.\nOutput:\n%3" )
|
|
||||||
.arg( m_command )
|
|
||||||
.arg( m_timeoutSec )
|
|
||||||
.arg( output ) );
|
|
||||||
|
|
||||||
//Any other exit code
|
|
||||||
return JobResult::error( tr( "External command finished with errors" ),
|
|
||||||
tr( "Command %1 finished with exit code %2.\nOutput:\n%3" )
|
|
||||||
.arg( m_command )
|
|
||||||
.arg( ec )
|
|
||||||
.arg( output ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,4 +145,40 @@ ProcessJob::callOutput( const QString& command,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JobResult
|
||||||
|
ProcessJob::explainProcess( int ec, const QString& command, const QString& output, int timeout )
|
||||||
|
{
|
||||||
|
if ( ec == 0 )
|
||||||
|
return JobResult::ok();
|
||||||
|
|
||||||
|
if ( ec == -1 ) //Crash!
|
||||||
|
return JobResult::error( tr( "External command crashed" ),
|
||||||
|
tr( "Command %1 crashed.\nOutput:\n%2" )
|
||||||
|
.arg( command )
|
||||||
|
.arg( output ) );
|
||||||
|
|
||||||
|
if ( ec == -2 )
|
||||||
|
return JobResult::error( tr( "External command failed to start" ),
|
||||||
|
tr( "Command %1 failed to start." )
|
||||||
|
.arg( command ) );
|
||||||
|
|
||||||
|
if ( ec == -3 )
|
||||||
|
return JobResult::error( tr( "Internal error when starting command" ),
|
||||||
|
tr( "Bad parameters for process job call." ) );
|
||||||
|
|
||||||
|
if ( ec == -4 )
|
||||||
|
return JobResult::error( tr( "External command failed to finish" ),
|
||||||
|
tr( "Command %1 failed to finish in %2s.\nOutput:\n%3" )
|
||||||
|
.arg( command )
|
||||||
|
.arg( timeout )
|
||||||
|
.arg( output ) );
|
||||||
|
|
||||||
|
//Any other exit code
|
||||||
|
return JobResult::error( tr( "External command finished with errors" ),
|
||||||
|
tr( "Command %1 finished with exit code %2.\nOutput:\n%3" )
|
||||||
|
.arg( command )
|
||||||
|
.arg( ec )
|
||||||
|
.arg( output ) );
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Calamares
|
} // namespace Calamares
|
||||||
|
|
|
@ -39,6 +39,10 @@ public:
|
||||||
QString prettyStatusMessage() const override;
|
QString prettyStatusMessage() const override;
|
||||||
JobResult exec() override;
|
JobResult exec() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** @brief Explain a typical external process failure. */
|
||||||
|
static JobResult explainProcess( int errorCode, const QString& command, const QString& output, int timeout );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int callOutput( const QString& command,
|
int callOutput( const QString& command,
|
||||||
QString& output,
|
QString& output,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue