Skip to content

Commit

Permalink
TgBot++: socket: DataHandler: Correctly log when type is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Jun 4, 2024
1 parent a5f9003 commit 6144381
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/socket/interface/impl/bot/SocketDataHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
#include <rapidjson/rapidjson.h>
#include <tgbot/types/InputFile.h>

#include <TgBotSocket_Export.hpp>
#include <chrono>
#include <filesystem>
#include <fstream>
#include <impl/bot/TgBotSocketFileHelper.hpp>
#include <impl/bot/TgBotSocketInterface.hpp>
#include <mutex>
#include <socket/TgBotCommandMap.hpp>
#include <utility>
#include <variant>

#include <TgBotSocket_Export.hpp>
#include <socket/TgBotCommandMap.hpp>
#include "tgbot/TgException.h"

using TgBot::Api;
using TgBot::InputFile;
Expand Down Expand Up @@ -145,7 +146,11 @@ GenericAck SocketInterfaceTgBot::handle_SendFileToChatId(const void* ptr) {
return GenericAck();
}
default:
fn = [](const Api&, ChatId, const FileOrId_t&) {
fn = [data](const Api&, ChatId, const FileOrId_t&) {
throw TgBot::TgException(
"Invalid file type: " +
std::to_string(static_cast<int>(data->fileType)),
TgBot::TgException::ErrorCode::Undefined);
return nullptr;
};
break;
Expand Down

0 comments on commit 6144381

Please sign in to comment.