MCPcopy Create free account
hub / github.com/MITK/MITK / LoadDataFromFile

Method LoadDataFromFile

Modules/RESTAPI/src/mitkDataStorageController.cpp:879–907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877}
878
879DataStorageController::LoadDataResult DataStorageController::LoadDataFromFile(
880 const std::string& filePath, const std::string& requestPath)
881{
882 LoadDataResult result;
883 result.success = false;
884 result.errorStatus = 0;
885
886 try
887 {
888 result.data = IOUtil::Load(filePath);
889 }
890 catch (const std::exception& e)
891 {
892 result.errorStatus = 422;
893 result.errorResponse = ErrorResponse::FileReadError(filePath, e.what(), requestPath);
894 return result;
895 }
896
897 if (result.data.empty() || result.data[0].IsNull())
898 {
899 result.errorStatus = 415;
900 result.errorResponse = ErrorResponse::UnsupportedFormat(
901 "No data could be loaded from file", requestPath);
902 return result;
903 }
904
905 result.success = true;
906 return result;
907}
908
909void DataStorageController::HandleGET_nodes(const httplib::Request& req, httplib::Response& res)
910{

Callers 2

Calls 4

LoadFunction · 0.85
whatMethod · 0.80
emptyMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected