Skip to content

Commit

Permalink
updated the verbosity of errors/warnings to be correct
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Sep 16, 2020
1 parent 1b4e7e1 commit e5033f7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions R/xnat_api.R
Expand Up @@ -304,15 +304,17 @@ xnat_connect <- function(base_url, username=NULL, password=NULL, xnat_name=NULL)
)
)
}
warning(
paste0(
"No username was given when running xnat_connect, you may be able to see ",
"public information from XNAT server. ", "To authenticate, pass",
" in username/password ", msg
if (!credentials_given) {
warning(
paste0(
"No username was given when running xnat_connect, you may be able to see ",
"public information from XNAT server. ", "To authenticate, pass",
" in username/password ", msg
)
)
)
}

if(parseHTTPHeader(header$value())['status'] >= 400) {
if (parseHTTPHeader(header$value())['status'] >= 400) {
msg = paste0("XNAT call failed, message: ",
parseHTTPHeader(header$value())['statusMessage'])
if (!credentials_given) {
Expand Down Expand Up @@ -660,10 +662,10 @@ xnat_connect <- function(base_url, username=NULL, password=NULL, xnat_name=NULL)
userpwd = paste(username, password, sep = ':'),
httpauth=1L)
status = parseHTTPHeader(header$value())['status']
if(status == 401) {
stop('bad username/password')
} else if(status != 200) {
stop('error authenticating')
if (parseHTTPHeader(header$value())['status'] >= 400) {
msg = paste0("XNAT call failed, message: ",
parseHTTPHeader(header$value())['statusMessage'])
stop(msg)
}
jsid <- reader$value()
}
Expand Down

0 comments on commit e5033f7

Please sign in to comment.