From fc839e671aba819d217bd957575237dbf6a45b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Fri, 6 Jan 2023 21:17:57 +0100 Subject: [PATCH] Manage ACSM files that contains server internal error --- include/libgourou_common.h | 3 ++- src/libgourou.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/libgourou_common.h b/include/libgourou_common.h index 2947b14..12a717e 100644 --- a/include/libgourou_common.h +++ b/include/libgourou_common.h @@ -64,7 +64,8 @@ namespace gourou FF_INVALID_ACSM_FILE, FF_NO_HMAC_IN_ACSM_FILE, FF_NOT_ACTIVATED, - FF_NO_OPERATOR_URL + FF_NO_OPERATOR_URL, + FF_SERVER_INTERNAL_ERROR }; enum DOWNLOAD_ERROR { diff --git a/src/libgourou.cpp b/src/libgourou.cpp index ec199d4..b4d56e1 100644 --- a/src/libgourou.cpp +++ b/src/libgourou.cpp @@ -505,6 +505,13 @@ namespace gourou if (!acsmDoc.load_file(ACSMFile.c_str(), pugi::parse_ws_pcdata_single|pugi::parse_escapes, pugi::encoding_utf8)) EXCEPTION(FF_INVALID_ACSM_FILE, "Invalid ACSM file " << ACSMFile); + // Could be an server internal error + pugi::xml_node rootNode = acsmDoc.first_child(); + if (std::string(rootNode.name()) == "error") + { + EXCEPTION(FF_SERVER_INTERNAL_ERROR, rootNode.attribute("data").value()); + } + GOUROU_LOG(INFO, "Fulfill " << ACSMFile); // Build req file @@ -512,7 +519,7 @@ namespace gourou buildFulfillRequest(acsmDoc, fulfillReq); pugi::xpath_node root = fulfillReq.select_node("//adept:fulfill"); - pugi::xml_node rootNode = root.node(); + rootNode = root.node(); // Remove HMAC pugi::xpath_node xpathRes = fulfillReq.select_node("//hmac");