Shaka Player Embedded
error.h
Go to the documentation of this file.
1 // Copyright 2016 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_ERROR_H_
16 #define SHAKA_EMBEDDED_ERROR_H_
17 
18 #include <iostream>
19 #include <memory>
20 #include <string>
21 
22 #include "macros.h"
23 
24 namespace shaka {
25 
34 class SHAKA_EXPORT Error final {
35  public:
37  Error(const std::string& message);
39  Error(int severity, int category, int code, const std::string& message);
40 
41  Error(const Error&);
42  Error(Error&&);
43  ~Error();
44 
45  Error& operator=(const Error&);
46  Error& operator=(Error&&);
47 
48 
49  // TODO: Consider adding the data field. Or consider adding a PrintError
50  // method to print it without requiring the app to depend on V8.
51 
53  std::string message;
58  int severity;
63  int category;
68  int code;
69 
70  private:
71  class Impl;
72  std::unique_ptr<Impl> impl_;
73 };
74 
75 inline std::ostream& operator<<(std::ostream& os, const Error& error) {
76  return os << error.message;
77 }
78 
79 } // namespace shaka
80 
81 #endif // SHAKA_EMBEDDED_ERROR_H_
int code
Definition: error.h:68
#define SHAKA_EXPORT
Definition: macros.h:30
int category
Definition: error.h:63
std::string message
Definition: error.h:53
int severity
Definition: error.h:58
std::ostream & operator<<(std::ostream &os, const Error &error)
Definition: error.h:75
const char * message