2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2018 The Dawn Authors
|
2018-05-25 20:23:44 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-07-24 14:42:33 +00:00
|
|
|
#ifndef DAWNNATIVE_ERRORDATA_H_
|
|
|
|
#define DAWNNATIVE_ERRORDATA_H_
|
2018-05-25 20:23:44 +00:00
|
|
|
|
2018-09-10 14:17:24 +00:00
|
|
|
#include <cstdint>
|
2020-02-18 02:44:05 +00:00
|
|
|
#include <memory>
|
2018-05-25 20:23:44 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
namespace wgpu {
|
2019-08-27 21:41:56 +00:00
|
|
|
enum class ErrorType : uint32_t;
|
|
|
|
}
|
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
namespace dawn {
|
|
|
|
using ErrorType = wgpu::ErrorType;
|
|
|
|
}
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
namespace dawn_native {
|
2019-08-27 21:41:56 +00:00
|
|
|
enum class InternalErrorType : uint32_t;
|
2018-09-10 14:17:24 +00:00
|
|
|
|
2018-05-25 20:23:44 +00:00
|
|
|
class ErrorData {
|
|
|
|
public:
|
2020-01-10 17:58:28 +00:00
|
|
|
static std::unique_ptr<ErrorData> Create(InternalErrorType type,
|
|
|
|
std::string message,
|
|
|
|
const char* file,
|
|
|
|
const char* function,
|
|
|
|
int line);
|
2019-08-27 21:41:56 +00:00
|
|
|
ErrorData(InternalErrorType type, std::string message);
|
2018-05-25 20:23:44 +00:00
|
|
|
|
|
|
|
struct BacktraceRecord {
|
|
|
|
const char* file;
|
|
|
|
const char* function;
|
|
|
|
int line;
|
|
|
|
};
|
|
|
|
void AppendBacktrace(const char* file, const char* function, int line);
|
|
|
|
|
2019-08-27 21:41:56 +00:00
|
|
|
InternalErrorType GetInternalType() const;
|
2019-10-23 11:57:41 +00:00
|
|
|
wgpu::ErrorType GetType() const;
|
2018-05-25 20:23:44 +00:00
|
|
|
const std::string& GetMessage() const;
|
|
|
|
const std::vector<BacktraceRecord>& GetBacktrace() const;
|
|
|
|
|
|
|
|
private:
|
2019-08-27 21:41:56 +00:00
|
|
|
InternalErrorType mType;
|
2018-05-25 20:23:44 +00:00
|
|
|
std::string mMessage;
|
|
|
|
std::vector<BacktraceRecord> mBacktrace;
|
|
|
|
};
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
} // namespace dawn_native
|
2018-05-25 20:23:44 +00:00
|
|
|
|
2018-07-24 14:42:33 +00:00
|
|
|
#endif // DAWNNATIVE_ERRORDATA_H_
|