Improve cmd error classification; add Git repository support
This commit is contained in:
@@ -2,6 +2,7 @@ const { Injectable } = require('flitter-di')
|
||||
const ImplementationError = require('libflitter/errors/ImplementationError')
|
||||
const PermissionDeniedError = require('../logical/error/PermissionDeniedError')
|
||||
const CommandNotFoundError = require('../logical/error/CommandNotFoundError')
|
||||
const FilesystemResourceNotFoundError = require('../logical/error/FilesystemResourceNotFoundError')
|
||||
const uuid = require('uuid/v4')
|
||||
const UniversalPath = require('../logical/UniversalPath')
|
||||
const SystemMetrics = require('../logical/SystemMetrics')
|
||||
@@ -181,7 +182,7 @@ class Host extends Injectable {
|
||||
const result = await this.execute(command)
|
||||
if ( result.exit_code !== 0 || result.clean_out.length < 1 ) {
|
||||
const E = this._get_result_error_class(result)
|
||||
throw new E('Unable to get line output from command: '+command)
|
||||
throw new E('Unable to get line output from command: '+command+'\n'+result.clean_err)
|
||||
}
|
||||
return this.utility.infer(result.clean_out[0].trim())
|
||||
}
|
||||
@@ -190,7 +191,7 @@ class Host extends Injectable {
|
||||
const result = await this.execute(command)
|
||||
if ( result.exit_code !== 0 ) {
|
||||
const E = this._get_result_error_class(result)
|
||||
throw new E('Unable to run command: '+command)
|
||||
throw new E('Unable to run command: '+command+'\n'+result.clean_err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -218,6 +219,13 @@ class Host extends Injectable {
|
||||
'command not found',
|
||||
]
|
||||
|
||||
const resource_not_found = [
|
||||
'no such file',
|
||||
'no such directory',
|
||||
'no such file or directory',
|
||||
'no such directory or file',
|
||||
]
|
||||
|
||||
for ( const phrase of access_denied_phrases ) {
|
||||
if ( both.includes(phrase) ) return PermissionDeniedError
|
||||
}
|
||||
@@ -226,6 +234,10 @@ class Host extends Injectable {
|
||||
if ( both.includes(phrase) ) return CommandNotFoundError
|
||||
}
|
||||
|
||||
for ( const phrase of resource_not_found ) {
|
||||
if ( both.includes(phrase) ) return FilesystemResourceNotFoundError
|
||||
}
|
||||
|
||||
return Error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user