DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
status.cc
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #include "packager/media/base/status.h"
8 
9 #include "packager/base/strings/stringprintf.h"
10 
11 namespace edash_packager {
12 namespace media {
13 
14 namespace error {
15 namespace {
16 std::string ErrorCodeToString(Code error_code) {
17  switch (error_code) {
18  case OK:
19  return "OK";
20  case UNKNOWN:
21  return "UNKNOWN";
22  case CANCELLED:
23  return "CANCELLED";
24  case INVALID_ARGUMENT:
25  return "INVALID_ARGUMENT";
26  case UNIMPLEMENTED:
27  return "UNIMPLEMENTED";
28  case FILE_FAILURE:
29  return "FILE_FAILURE";
30  case END_OF_STREAM:
31  return "END_OF_STREAM";
32  case HTTP_FAILURE:
33  return "HTTP_FAILURE";
34  case PARSER_FAILURE:
35  return "PARSER_FAILURE";
36  case MUXER_FAILURE:
37  return "MUXER_FAILURE";
38  case FRAGMENT_FINALIZED:
39  return "FRAGMENT_FINALIZED";
40  case SERVER_ERROR:
41  return "SERVER_ERROR";
42  case INTERNAL_ERROR:
43  return "INTERNAL_ERROR";
44  case STOPPED:
45  return "STOPPED";
46  case TIME_OUT:
47  return "TIME_OUT";
48  default:
49  NOTIMPLEMENTED() << "Unknown Status Code: " << error_code;
50  return "UNKNOWN_STATUS";
51  }
52 }
53 } // namespace
54 } // namespace error
55 
56 const Status& Status::OK = Status(error::OK, "");
57 const Status& Status::UNKNOWN = Status(error::UNKNOWN, "");
58 
59 std::string Status::ToString() const {
60  if (error_code_ == error::OK)
61  return "OK";
62 
63  return base::StringPrintf("%d (%s): %s",
64  error_code_,
65  error::ErrorCodeToString(error_code_).c_str(),
66  error_message_.c_str());
67 }
68 
69 std::ostream& operator<<(std::ostream& os, const Status& x) {
70  os << x.ToString();
71  return os;
72 }
73 
74 } // namespace media
75 } // namespace edash_packager
std::string ToString() const
Definition: status.cc:59