Make Dawn error macro more explicit and have an "error type"

The error type will help distinguish between validation errors, context
losts and others which should be handled differently.

Take advantage of advantage of this to change DAWN_RETURN_ERROR to
"return DAWN_FOO_ERROR" to have the return be more explicit. Also
removes usage of DAWN_TRY_ASSERT for more explicit checks.

Change-Id: Icbce16b0c8d8eb084b0af2fc132acee776909a36
This commit is contained in:
Corentin Wallez
2018-09-10 16:17:24 +02:00
committed by Corentin Wallez
parent cca9c698a0
commit 6fee61ca9c
16 changed files with 132 additions and 86 deletions

View File

@@ -15,15 +15,18 @@
#ifndef DAWNNATIVE_ERRORDATA_H_
#define DAWNNATIVE_ERRORDATA_H_
#include <cstdint>
#include <string>
#include <vector>
namespace dawn_native {
enum class ErrorType : uint32_t;
class ErrorData {
public:
ErrorData();
ErrorData(std::string message);
ErrorData(ErrorType type, std::string message);
struct BacktraceRecord {
const char* file;
@@ -32,10 +35,12 @@ namespace dawn_native {
};
void AppendBacktrace(const char* file, const char* function, int line);
ErrorType GetType() const;
const std::string& GetMessage() const;
const std::vector<BacktraceRecord>& GetBacktrace() const;
private:
ErrorType mType;
std::string mMessage;
std::vector<BacktraceRecord> mBacktrace;
};