Remove special case for empty response body

Not sure if this served a purpose, so let's find out.
This commit is contained in:
Tim Pope
2022-06-15 16:09:39 -04:00
parent 2f1a84f0d6
commit f8b70f5ef3

View File

@@ -201,19 +201,23 @@ function! rhubarb#Request(path, ...) abort
\ { r -> r.exit_status || r.stdout ==# [''] ? '' : call(options.callback, [json_decode(join(r.stdout, ' '))] + get(options, 'callback_args', [])) })
endif
let raw = join(FugitiveExecute({'argv': args}).stdout, ' ')
return empty(raw) ? raw : json_decode(raw)
if empty(raw)
throw 'rhubarb: bug? empty response from ' . path
else
return json_decode(raw)
endif
catch /^fugitive:/
endtry
endif
let raw = system(join(map(copy(args), 's:shellesc(v:val)'), ' '))
silent let raw = system(join(map(copy(args), 's:shellesc(v:val)'), ' '))
if has_key(options, 'callback')
if !v:shell_error && !empty(raw)
call call(options.callback, [rhubarb#JsonDecode(raw)] + get(options, 'callback_args', []))
endif
return {}
endif
if raw ==# ''
return raw
if empty(raw)
throw 'rhubarb: bug? empty response from ' . path
else
return rhubarb#JsonDecode(raw)
endif
@@ -263,9 +267,7 @@ function! rhubarb#Complete(findstart, base) abort
let query = a:base
endif
let response = rhubarb#RepoSearch('issues', 'state:open '.query)
if type(response) != type({})
call s:throw('unknown error')
elseif has_key(response, 'message')
if has_key(response, 'message')
call s:throw(response.message)
else
let issues = get(response, 'items', [])