diff --git a/src/value.cc b/src/value.cc index 03a9dd47..997cc4e7 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1368,8 +1368,15 @@ void FreeGIArgumentArray(GITypeInfo *type_info, GIArgument *arg, GITransfer tran */ bool CanConvertV8ToGValue(GValue *gvalue, Local value) { + auto maybeDetailString = Nan::ToDetailString(value); + Nan::Utf8String utf8String( + !maybeDetailString.IsEmpty() ? + maybeDetailString.ToLocalChecked() : + UTF8("[invalid value]") + ); + // void/null - if (G_VALUE_TYPE(gvalue) == G_TYPE_INVALID) + if (G_VALUE_TYPE(gvalue) == G_TYPE_INVALID || strcmp(*utf8String,"undefined") == 0) return value->IsNullOrUndefined(); if (G_VALUE_HOLDS_BOOLEAN (gvalue)) { @@ -1426,8 +1433,7 @@ bool V8ToGValue(GValue *gvalue, Local value, bool mustCopy) { maybeDetailString.ToLocalChecked() : UTF8("[invalid value]") ); - Throw::TypeError("Cannot convert value \"%s\" to type %s", - *utf8String, G_VALUE_TYPE_NAME (gvalue)); + Throw::TypeError("Cannot convert value \"%s\" to type %s",*utf8String, G_VALUE_TYPE_NAME (gvalue)); return false; }