diff options
author | 2018-07-27 14:03:25 -0700 | |
---|---|---|
committer | 2018-07-27 14:07:05 -0700 | |
commit | 81d927bfc7e1e4c7b28aabdb0c64a12cec2833fe (patch) | |
tree | db8ce58fcb792df76624a5e3f94d502a16aba1bf /tensorflow/core/lib | |
parent | 388d0d860110a19a9d133fe4de85f8f6fa060cde (diff) |
Adding NodeDef names to error messages for better debuggability.
The format used is as follows:
{{node <node_name>}}
PiperOrigin-RevId: 206370355
Diffstat (limited to 'tensorflow/core/lib')
-rw-r--r-- | tensorflow/core/lib/core/errors.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tensorflow/core/lib/core/errors.h b/tensorflow/core/lib/core/errors.h index 51c09032df..a631d9815a 100644 --- a/tensorflow/core/lib/core/errors.h +++ b/tensorflow/core/lib/core/errors.h @@ -19,6 +19,7 @@ limitations under the License. #include <sstream> #include "tensorflow/core/lib/core/status.h" +#include "tensorflow/core/lib/strings/str_util.h" #include "tensorflow/core/lib/strings/strcat.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/macros.h" @@ -118,6 +119,25 @@ DECLARE_ERROR(Unauthenticated, UNAUTHENTICATED) #undef DECLARE_ERROR +// Produces a formatted string pattern from the name which can uniquely identify +// this node upstream to produce an informative error message. The pattern +// followed is: {{node <name>}} +// Note: The pattern below determines the regex _NODEDEF_NAME_RE in the file +// tensorflow/python/client/session.py +// LINT.IfChange +inline string FormatNodeNameForError(const string& name) { + return strings::StrCat("{{node ", name, "}}"); +} +// LINT.ThenChange(//tensorflow/python/client/session.py) +template <typename T> +string FormatNodeNamesForError(const T& names) { + ::tensorflow::str_util::Formatter<string> f( + [](string* output, const string& s) { + ::tensorflow::strings::StrAppend(output, FormatNodeNameForError(s)); + }); + return ::tensorflow::str_util::Join(names, ", ", f); +} + // The CanonicalCode() for non-errors. using ::tensorflow::error::OK; |