chore: add error throwing utility (#19803)

* chore: add error throwing utility

* feedback from review

* DRY out repeated isolate calls
This commit is contained in:
Shelley Vohr 2019-08-19 09:10:18 -07:00 committed by GitHub
parent 8f1c51eaea
commit 43e6d7fe88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 4 deletions

View file

@ -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>