mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 16:40:04 +00:00 
			
		
		
		
	JSON write error handling
This commit is contained in:
		
							parent
							
								
									b1e1297e0d
								
							
						
					
					
						commit
						6373728242
					
				
					 1 changed files with 12 additions and 4 deletions
				
			
		|  | @ -95,15 +95,23 @@ void WriteJsonFile(const std::string&        path, | ||||||
| { | { | ||||||
|    std::ofstream ofs {path}; |    std::ofstream ofs {path}; | ||||||
| 
 | 
 | ||||||
|    if (prettyPrint) |    if (!ofs.is_open()) | ||||||
|    { |    { | ||||||
|       PrettyPrintJson(ofs, json); |       BOOST_LOG_TRIVIAL(warning) | ||||||
|  |          << logPrefix_ << "Cannot write JSON file: \"" << path << "\""; | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|    { |    { | ||||||
|       ofs << json; |       if (prettyPrint) | ||||||
|  |       { | ||||||
|  |          PrettyPrintJson(ofs, json); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |          ofs << json; | ||||||
|  |       } | ||||||
|  |       ofs.close(); | ||||||
|    } |    } | ||||||
|    ofs.close(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void PrettyPrintJson(std::ostream&             os, | static void PrettyPrintJson(std::ostream&             os, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat