7 #include "packager/status.h" 9 #include "packager/base/logging.h" 10 #include "packager/base/strings/stringprintf.h" 16 std::string ErrorCodeToString(Code error_code) {
24 case INVALID_ARGUMENT:
25 return "INVALID_ARGUMENT";
27 return "UNIMPLEMENTED";
29 return "FILE_FAILURE";
31 return "END_OF_STREAM";
33 return "HTTP_FAILURE";
35 return "PARSER_FAILURE";
36 case ENCRYPTION_FAILURE:
37 return "ENCRYPTION_FAILURE";
39 return "CHUNKING_ERROR";
41 return "MUXER_FAILURE";
42 case FRAGMENT_FINALIZED:
43 return "FRAGMENT_FINALIZED";
45 return "SERVER_ERROR";
47 return "INTERNAL_ERROR";
55 return "ALREADY_EXISTS";
57 NOTIMPLEMENTED() <<
"Unknown Status Code: " << error_code;
58 return "UNKNOWN_STATUS";
64 const Status Status::OK = Status(error::OK,
"");
65 const Status Status::UNKNOWN = Status(error::UNKNOWN,
"");
68 : error_code_(error_code) {
70 error_message_ = error_message;
71 if (!error_message.empty())
78 *
this = std::move(new_status);
82 if (error_code_ == error::OK)
85 return base::StringPrintf(
"%d (%s): %s",
87 error::ErrorCodeToString(error_code_).c_str(),
88 error_message_.c_str());
91 std::ostream& operator<<(std::ostream& os,
const Status& x) {
std::string ToString() const
All the methods that are virtual are virtual for mocking.
Status()
Creates a "successful" status.
void Update(Status new_status)