dawn-cmake/src/backend/ErrorData.cpp
Corentin Wallez 1fda980fa6 Add an Error and ResultOrError<T> type and tests
These types are meant to be used for computations that might but are not
expected to fail in backend/, such that the error case can be much
slower than the success case.

The NXT_TRY and NXT_TRY_RESULT macros are added to help write more
concise code that uses Error and ResultOrError.
2018-05-31 15:00:28 -04:00

42 lines
1.2 KiB
C++

// Copyright 2018 The NXT Authors
//
// 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.
#include "backend/ErrorData.h"
namespace backend {
ErrorData::ErrorData() = default;
ErrorData::ErrorData(std::string message) : mMessage(std::move(message)) {
}
void ErrorData::AppendBacktrace(const char* file, const char* function, int line) {
BacktraceRecord record;
record.file = file;
record.function = function;
record.line = line;
mBacktrace.push_back(std::move(record));
}
const std::string& ErrorData::GetMessage() const {
return mMessage;
}
const std::vector<ErrorData::BacktraceRecord>& ErrorData::GetBacktrace() const {
return mBacktrace;
}
} // namespace backend