chore: add error throwing utility (#19803)
* chore: add error throwing utility * feedback from review * DRY out repeated isolate calls
This commit is contained in:
parent
8f1c51eaea
commit
43e6d7fe88
7 changed files with 118 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
|||
#ifndef NATIVE_MATE_NATIVE_MATE_FUNCTION_TEMPLATE_H_
|
||||
#define NATIVE_MATE_NATIVE_MATE_FUNCTION_TEMPLATE_H_
|
||||
|
||||
#include "../shell/common/error_util.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/logging.h"
|
||||
#include "native_mate/arguments.h"
|
||||
|
@ -128,6 +129,16 @@ inline bool GetNextArgument(Arguments* args,
|
|||
return true;
|
||||
}
|
||||
|
||||
// Allow clients to pass a util::Error to throw errors if they
|
||||
// don't need the full mate::Arguments
|
||||
inline bool GetNextArgument(Arguments* args,
|
||||
int create_flags,
|
||||
bool is_first,
|
||||
electron::util::ErrorThrower* result) {
|
||||
*result = electron::util::ErrorThrower(args->isolate());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Classes for generating and storing an argument pack of integer indices
|
||||
// (based on well-known "indices trick", see: http://goo.gl/bKKojn):
|
||||
template <size_t... indices>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue