1 // Copyright 2018 The Dawn Authors 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 // http://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 DAWNNATIVE_ERRORDATA_H_ 16 #define DAWNNATIVE_ERRORDATA_H_ 17 18 #include <cstdint> 19 #include <string> 20 #include <vector> 21 22 namespace dawn_native { 23 24 enum class ErrorType : uint32_t; 25 26 class ErrorData { 27 public: 28 ErrorData(); 29 ErrorData(ErrorType type, std::string message); 30 31 struct BacktraceRecord { 32 const char* file; 33 const char* function; 34 int line; 35 }; 36 void AppendBacktrace(const char* file, const char* function, int line); 37 38 ErrorType GetType() const; 39 const std::string& GetMessage() const; 40 const std::vector<BacktraceRecord>& GetBacktrace() const; 41 42 private: 43 ErrorType mType; 44 std::string mMessage; 45 std::vector<BacktraceRecord> mBacktrace; 46 }; 47 48 } // namespace dawn_native 49 50 #endif // DAWNNATIVE_ERRORDATA_H_ 51