Skip to content

Commit

Permalink
error message extraction fix for json output
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed Dec 11, 2024
1 parent ef00dac commit 414d82f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/body.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ setGemmaPath <- function(path){
} else if (response$status_code == 503) {
stop(call,'\n',response$status_code, ": Service Unavailable. Gemma might be under maintenance.")
} else {
message = response$content %>% rawToChar() %>% strsplit('\n') %>% {.[[1]]} %>% {.[grepl('Message',.)]} %>% stringr::str_extract('(?<=Message: ).*')
if(isFile){
message <- response$content %>% rawToChar() %>% strsplit('\n') %>% {.[[1]]} %>% {.[grepl('Message',.)]} %>% stringr::str_extract('(?<=Message: ).*')
} else{
message <- response$content %>% rawToChar() %>% jsonlite::fromJSON() %>% {.$error$message}
}
stop(call, '\n', "HTTP code ", response$status_code,": ",message)
}
}
Expand Down

0 comments on commit 414d82f

Please sign in to comment.