Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 22a160a

Browse files
api fails gracefully
1 parent 8bfd940 commit 22a160a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

R/espa_user.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ espa_user <- function(host = 'https://espa.cr.usgs.gov/api/v1/', username = NULL
3333
}, error = function(err){
3434
cat("Status Code from ESPA API:",result$status_code,"\n")
3535
print(result)
36-
stop("Cannot Connect to ESPA APIs. Please check https://espa.cr.usgs.gov/api/v1/user for details\n")
36+
return("Cannot Connect to ESPA APIs. Please check https://espa.cr.usgs.gov/api/v1/user for details\n")
3737
})
3838

3939
if(length(user_role)>0){

R/utils.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,10 @@ satapilsat8 <- function(date_from = "2013-04-01", date_to = Sys.Date(), limit =
7979
# suppressWarnings(suppressMessages(library(httr)))
8080
if(is.null(row) | is.null(path)){
8181
link = paste0('https://api.developmentseed.org/satellites/?limit=',limit,'$satellite_name=landsat-8&date_from=',date_from,'&date_to=',date_to)
82-
result = httr::GET(link)
8382
} else{
8483
link = paste0('https://api.developmentseed.org/satellites/?limit=',limit,'$satellite_name=landsat-8&date_from=',date_from,'&date_to=',date_to,'&path=',path,'&row=',row)
85-
result = httr::GET(link)
8684
}
85+
result = httr::GET(link)
8786
if(result$status_code != 200){
8887
print(paste("Error:",result$status_code))
8988
}
@@ -134,3 +133,6 @@ StandardColnames <- function (dataframe){
134133
colnames(dataframe) = stringr::str_to_lower(colnames(dataframe))
135134
return(dataframe)
136135
}
136+
137+
138+

0 commit comments

Comments
 (0)