electron/shell/common/gin_helper/error_thrower.h
Cheng Zhao 2c23e44ed9
chore: remove native_mate (Part 3) (#20131)
* use gin converter in atom_api_menu

* please only put necessary includes in header

Having include in header means they have dependency relationship,
putting arbitrary includes really really really really really makes
refacoring much harder.

* remove some simple uses of callback_converter_deprecated.h

* use gin callback converter in file_dialog code

* use gin in ErrorThrower

* use gin in atom_bundle_mover

* fix mistake in node stream

* deprecate native_mate version of event_emitter_caller

* use gin in node_bindings

* remove usages of native_mate event_emitter_caller.h except for EventEmitter

* fix compilation on Windows

* gin::Arguments behaves differently on GetNext

* just use StringToV8
2019-09-06 14:52:54 +09:00

38 lines
1,019 B
C++

// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_COMMON_GIN_HELPER_ERROR_THROWER_H_
#define SHELL_COMMON_GIN_HELPER_ERROR_THROWER_H_
#include "base/strings/string_piece.h"
#include "v8/include/v8.h"
namespace gin_helper {
class ErrorThrower {
public:
explicit ErrorThrower(v8::Isolate* isolate);
ErrorThrower();
~ErrorThrower();
void ThrowError(base::StringPiece err_msg);
void ThrowTypeError(base::StringPiece err_msg);
void ThrowRangeError(base::StringPiece err_msg);
void ThrowReferenceError(base::StringPiece err_msg);
void ThrowSyntaxError(base::StringPiece err_msg);
v8::Isolate* isolate() const { return isolate_; }
private:
using ErrorGenerator =
v8::Local<v8::Value> (*)(v8::Local<v8::String> err_msg);
void Throw(ErrorGenerator gen, base::StringPiece err_msg);
v8::Isolate* isolate_;
};
} // namespace gin_helper
#endif // SHELL_COMMON_GIN_HELPER_ERROR_THROWER_H_