From 23aad092275a65827d786b8d85c87d63adec8f6c Mon Sep 17 00:00:00 2001 From: NotAdam Date: Tue, 29 Oct 2019 18:49:27 +1100 Subject: [PATCH] handle bad json in exd_struct_gen --- src/tools/exd_struct_gen/main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tools/exd_struct_gen/main.cpp b/src/tools/exd_struct_gen/main.cpp index c418dd61..1fbcb042 100644 --- a/src/tools/exd_struct_gen/main.cpp +++ b/src/tools/exd_struct_gen/main.cpp @@ -127,8 +127,17 @@ std::string generateStruct( const std::string& exd ) } auto sheet = nlohmann::json(); - std::ifstream defJson( path ); - defJson >> sheet; + + try + { + std::ifstream defJson( path ); + defJson >> sheet; + } + catch( const std::exception& ex ) + { + Logger::error( "Failed parsing json definition, err: {} file: {}", ex.what(), path ); + return ""; + } for( auto& definition : sheet[ "definitions" ] ) {