Representing errors
Created by: wangkuiyi
In old Unix world, errors are represented by a non-zero integer.
In the Web world, errors are often represented by an integer and a message string. TensorFlow adopted this idea and have Status
:
class Status {
...
private:
static const string& empty_string();
struct State {
tensorflow::error::Code code;
string msg;
};
// OK status has a `NULL` state_. Otherwise, `state_` points to
// a `State` structure containing the error code and message(s)
State* state_;
...
};
Go represents an error by a string.
I personally prefer Go's approach because integers are not readable and the integer-plus-string approach is redundant. What do you think, dear PaddlePaddle authors?