mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 06:30:54 +00:00
GenerateText gives text error on failure
This commit is contained in:
@@ -36,6 +36,8 @@ class CodeGenerator {
|
||||
NOT_IMPLEMENTED = 3
|
||||
};
|
||||
|
||||
std::string status_detail;
|
||||
|
||||
// Generate code from the provided `parser`.
|
||||
//
|
||||
// DEPRECATED: prefer using the other overload of GenerateCode for bfbs.
|
||||
|
||||
@@ -1200,13 +1200,14 @@ class Parser : public ParserState {
|
||||
// strict_json adds "quotes" around field names if true.
|
||||
// If the flatbuffer cannot be encoded in JSON (e.g., it contains non-UTF-8
|
||||
// byte arrays in String values), returns false.
|
||||
extern bool GenerateTextFromTable(const Parser &parser, const void *table,
|
||||
const std::string &tablename,
|
||||
std::string *text);
|
||||
extern bool GenerateText(const Parser &parser, const void *flatbuffer,
|
||||
std::string *text);
|
||||
extern bool GenerateTextFile(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name);
|
||||
extern const char *GenerateTextFromTable(const Parser &parser, const void *table,
|
||||
const std::string &tablename,
|
||||
std::string *text);
|
||||
extern const char *GenerateText(const Parser &parser, const void *flatbuffer,
|
||||
std::string *text);
|
||||
extern const char *GenerateTextFile(const Parser &parser,
|
||||
const std::string &path,
|
||||
const std::string &file_name);
|
||||
|
||||
// Generate Json schema to string
|
||||
// See idl_gen_json_schema.cpp.
|
||||
|
||||
@@ -52,8 +52,10 @@ class Registry {
|
||||
Parser parser;
|
||||
if (!LoadSchema(ident, &parser)) return false;
|
||||
// Now we're ready to generate text.
|
||||
if (!GenerateText(parser, flatbuf, dest)) {
|
||||
lasterror_ = "unable to generate text for FlatBuffer binary";
|
||||
auto err = GenerateText(parser, flatbuf, dest);
|
||||
if (err) {
|
||||
lasterror_ = "unable to generate text for FlatBuffer binary: " +
|
||||
std::string(err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user