From: Joshua C. Randall Date: Mon, 22 Feb 2016 22:20:48 +0000 (+0000) Subject: Adds better error reporting for problems with request body file X-Git-Tag: 1.1.0~902^2~2^2~1 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/212fa4898c594211217444b20ef629157813bc4a Adds better error reporting for problems with request body file Reports clear error messages if the specified file does not exist or is not readable. --- diff --git a/sdk/cli/bin/arv b/sdk/cli/bin/arv index 6811a4473f..b91d137a48 100755 --- a/sdk/cli/bin/arv +++ b/sdk/cli/bin/arv @@ -643,7 +643,17 @@ if resource_body if resource_body == '-' _resource_body_file = $stdin else - _resource_body_file = File.open(resource_body, 'r') + if File.readable? resource_body + _resource_body_file = File.open(resource_body, 'r') + else + if File.exists? resource_body + # specified file exists but is not readable + abort "File '#{resource_body}' specified for option '--#{resource_schema.to_sym}' exists but is not readable." + else + # specified file does not exist + abort "File '#{resource_body}' specified for option '--#{resource_schema.to_sym}' does not exist." + end + end end resource_body = _resource_body_file.read() _resource_body_file.close()