From 406050976b98e6da4b0dda6ee577fd9a89d12c6d Mon Sep 17 00:00:00 2001 From: afwillia Date: Tue, 20 Feb 2024 13:28:36 -0800 Subject: [PATCH] Remove error handling from API wrapper functions, put in other functions --- R/schematic_rest_api.R | 29 ++++++++++++++--------------- functions/schematic_rest_api.R | 29 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/R/schematic_rest_api.R b/R/schematic_rest_api.R index c2573c84..ad317c57 100644 --- a/R/schematic_rest_api.R +++ b/R/schematic_rest_api.R @@ -113,7 +113,6 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate", schema_url="https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", #nolint data_type, file_name = NULL, restrict_rules=FALSE, project_scope = NULL, access_token, asset_view = NULL, json_str = NULL) { - a <- paste0(sample(1000, 1), "-") flattenbody <- function(x) { # A form/query can only have one value per name, so take # any values that contain vectors length >1 and @@ -177,20 +176,20 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate", } # Format server error in a way validationResult can handle - if (httr2::resp_is_error(resp)) { - return( - list( - list( - "errors" = list( - Row = NA, Column = NA, Value = NA, - Error = sprintf("Cannot validate manifest: %s", - httr2::resp_status_desc(resp) - ) - ) - ) - ) - ) - } + # if (httr2::resp_is_error(resp)) { + # return( + # list( + # list( + # "errors" = list( + # Row = NA, Column = NA, Value = NA, + # Error = sprintf("Cannot validate manifest: %s", + # httr2::resp_status_desc(resp) + # ) + # ) + # ) + # ) + # ) + # } httr2::resp_body_json(resp) } diff --git a/functions/schematic_rest_api.R b/functions/schematic_rest_api.R index c2573c84..ad317c57 100644 --- a/functions/schematic_rest_api.R +++ b/functions/schematic_rest_api.R @@ -113,7 +113,6 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate", schema_url="https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", #nolint data_type, file_name = NULL, restrict_rules=FALSE, project_scope = NULL, access_token, asset_view = NULL, json_str = NULL) { - a <- paste0(sample(1000, 1), "-") flattenbody <- function(x) { # A form/query can only have one value per name, so take # any values that contain vectors length >1 and @@ -177,20 +176,20 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate", } # Format server error in a way validationResult can handle - if (httr2::resp_is_error(resp)) { - return( - list( - list( - "errors" = list( - Row = NA, Column = NA, Value = NA, - Error = sprintf("Cannot validate manifest: %s", - httr2::resp_status_desc(resp) - ) - ) - ) - ) - ) - } + # if (httr2::resp_is_error(resp)) { + # return( + # list( + # list( + # "errors" = list( + # Row = NA, Column = NA, Value = NA, + # Error = sprintf("Cannot validate manifest: %s", + # httr2::resp_status_desc(resp) + # ) + # ) + # ) + # ) + # ) + # } httr2::resp_body_json(resp) }