xref: /aosp_15_r20/external/skia/src/sksl/SkSLErrorReporter.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2021 Google LLC.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/sksl/SkSLErrorReporter.h"
9 
10 #include "src/base/SkStringView.h"
11 #include "src/sksl/SkSLCompiler.h"
12 #include "src/sksl/SkSLPosition.h"
13 
14 namespace SkSL {
15 
error(Position position,std::string_view msg)16 void ErrorReporter::error(Position position, std::string_view msg) {
17     if (skstd::contains(msg, Compiler::POISON_TAG)) {
18         // Don't report errors on poison values.
19         return;
20     }
21     ++fErrorCount;
22     this->handleError(msg, position);
23 }
24 
handleError(std::string_view msg,Position pos)25 void TestingOnly_AbortErrorReporter::handleError(std::string_view msg, Position pos) {
26     SK_ABORT("%.*s", (int)msg.length(), msg.data());
27 }
28 
29 } // namespace SkSL
30