| 877 | } |
| 878 | |
| 879 | DataStorageController::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 | |
| 909 | void DataStorageController::HandleGET_nodes(const httplib::Request& req, httplib::Response& res) |
| 910 | { |
no test coverage detected