7 #include <packager/status.h>
9 #include <absl/log/log.h>
10 #include <absl/strings/str_format.h>
12 #include <packager/macros/logging.h>
18 const char* ErrorCodeToString(Code error_code) {
26 case INVALID_ARGUMENT:
27 return "INVALID_ARGUMENT";
29 return "UNIMPLEMENTED";
31 return "FILE_FAILURE";
33 return "END_OF_STREAM";
35 return "HTTP_FAILURE";
37 return "PARSER_FAILURE";
38 case ENCRYPTION_FAILURE:
39 return "ENCRYPTION_FAILURE";
41 return "CHUNKING_ERROR";
43 return "MUXER_FAILURE";
44 case FRAGMENT_FINALIZED:
45 return "FRAGMENT_FINALIZED";
47 return "SERVER_ERROR";
49 return "INTERNAL_ERROR";
57 return "ALREADY_EXISTS";
58 case TRICK_PLAY_ERROR:
59 return "TRICK_PLAY_ERROR";
62 NOTIMPLEMENTED() <<
"Unknown Status Code: " << error_code;
63 return "UNKNOWN_STATUS";
68 const Status Status::OK = Status(error::OK,
"");
69 const Status Status::UNKNOWN = Status(error::UNKNOWN,
"");
71 Status::Status(error::Code error_code,
const std::string& error_message)
72 : error_code_(error_code) {
74 error_message_ = error_message;
75 if (!error_message.empty())
76 VLOG(1) << ToString();
80 void Status::Update(Status new_status) {
82 *
this = std::move(new_status);
85 std::string Status::ToString()
const {
86 if (error_code_ == error::OK)
89 return absl::StrFormat(
"%d (%s): %s", error_code_,
90 error::ErrorCodeToString(error_code_),
91 error_message_.c_str());
94 std::ostream& operator<<(std::ostream& os,
const Status& x) {
All the methods that are virtual are virtual for mocking.