Commit cc1810b3 by Marcin Cieślak

Less bureaucracy for Nan::ThrowTypeError

parent 00ea12cf
......@@ -54,12 +54,12 @@ namespace SassTypes
if (info.IsConstructCall()) {
if (constructor_locked) {
return Nan::ThrowTypeError(Nan::New("Cannot instantiate SassBoolean").ToLocalChecked());
return Nan::ThrowTypeError("Cannot instantiate SassBoolean");
}
}
else {
if (info.Length() != 1 || !info[0]->IsBoolean()) {
return Nan::ThrowTypeError(Nan::New("Expected one boolean argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected one boolean argument");
}
info.GetReturnValue().Set(get_singleton(Nan::To<bool>(info[0]).FromJust()).get_js_object());
......
......@@ -79,11 +79,11 @@ namespace SassTypes
NAN_METHOD(Color::SetR) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a number").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a number");
}
sass_color_set_r(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
......@@ -91,11 +91,11 @@ namespace SassTypes
NAN_METHOD(Color::SetG) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a number").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a number");
}
sass_color_set_g(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
......@@ -103,11 +103,11 @@ namespace SassTypes
NAN_METHOD(Color::SetB) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a number").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a number");
}
sass_color_set_b(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
......@@ -115,11 +115,11 @@ namespace SassTypes
NAN_METHOD(Color::SetA) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a number").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a number");
}
sass_color_set_a(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
......
......@@ -40,7 +40,7 @@ namespace SassTypes
default:
const char *msg = "Unknown type encountered.";
Nan::ThrowTypeError(Nan::New<v8::String>(msg).ToLocalChecked());
Nan::ThrowTypeError(msg);
return new Error(sass_make_error(msg));
}
}
......
......@@ -39,11 +39,11 @@ namespace SassTypes
NAN_METHOD(List::GetValue) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied index should be an integer").ToLocalChecked());
return Nan::ThrowTypeError("Supplied index should be an integer");
}
Sass_Value* list = unwrap(info.This())->value;
......@@ -59,22 +59,22 @@ namespace SassTypes
NAN_METHOD(List::SetValue) {
if (info.Length() != 2) {
return Nan::ThrowTypeError(Nan::New("Expected two arguments").ToLocalChecked());
return Nan::ThrowTypeError("Expected two arguments");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied index should be an integer").ToLocalChecked());
return Nan::ThrowTypeError("Supplied index should be an integer");
}
if (!info[1]->IsObject()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a SassValue object").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a SassValue object");
}
Value* sass_value = Factory::unwrap(info[1]);
if (sass_value) {
sass_list_set_value(unwrap(info.This())->value, Nan::To<uint32_t>(info[0]).FromJust(), sass_value->get_sass_value());
} else {
Nan::ThrowTypeError(Nan::New<v8::String>("A SassValue is expected as the list item").ToLocalChecked());
Nan::ThrowTypeError("A SassValue is expected as the list item");
}
}
......@@ -84,11 +84,11 @@ namespace SassTypes
NAN_METHOD(List::SetSeparator) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsBoolean()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a boolean").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a boolean");
}
sass_list_set_separator(unwrap(info.This())->value, Nan::To<bool>(info[0]).FromJust() ? SASS_COMMA : SASS_SPACE);
......
......@@ -30,11 +30,11 @@ namespace SassTypes
NAN_METHOD(Map::GetValue) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied index should be an integer").ToLocalChecked());
return Nan::ThrowTypeError("Supplied index should be an integer");
}
Sass_Value* map = unwrap(info.This())->value;
......@@ -50,33 +50,33 @@ namespace SassTypes
NAN_METHOD(Map::SetValue) {
if (info.Length() != 2) {
return Nan::ThrowTypeError(Nan::New("Expected two arguments").ToLocalChecked());
return Nan::ThrowTypeError("Expected two arguments");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied index should be an integer").ToLocalChecked());
return Nan::ThrowTypeError("Supplied index should be an integer");
}
if (!info[1]->IsObject()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a SassValue object").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a SassValue object");
}
Value* sass_value = Factory::unwrap(info[1]);
if (sass_value) {
sass_map_set_value(unwrap(info.This())->value, Nan::To<uint32_t>(info[0]).FromJust(), sass_value->get_sass_value());
} else {
Nan::ThrowTypeError(Nan::New<v8::String>("A SassValue is expected as a map value").ToLocalChecked());
Nan::ThrowTypeError("A SassValue is expected as a map value");
}
}
NAN_METHOD(Map::GetKey) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied index should be an integer").ToLocalChecked());
return Nan::ThrowTypeError("Supplied index should be an integer");
}
Sass_Value* map = unwrap(info.This())->value;
......@@ -92,22 +92,22 @@ namespace SassTypes
NAN_METHOD(Map::SetKey) {
if (info.Length() != 2) {
return Nan::ThrowTypeError(Nan::New("Expected two arguments").ToLocalChecked());
return Nan::ThrowTypeError("Expected two arguments");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied index should be an integer").ToLocalChecked());
return Nan::ThrowTypeError("Supplied index should be an integer");
}
if (!info[1]->IsObject()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a SassValue object").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a SassValue object");
}
Value* sass_value = Factory::unwrap(info[1]);
if (sass_value) {
sass_map_set_key(unwrap(info.This())->value, Nan::To<uint32_t>(info[0]).FromJust(), sass_value->get_sass_value());
} else {
Nan::ThrowTypeError(Nan::New<v8::String>("A SassValue is expected as a map key").ToLocalChecked());
Nan::ThrowTypeError("A SassValue is expected as a map key");
}
}
......
......@@ -49,7 +49,7 @@ namespace SassTypes
if (info.IsConstructCall()) {
if (constructor_locked) {
return Nan::ThrowTypeError(Nan::New("Cannot instantiate SassNull").ToLocalChecked());
return Nan::ThrowTypeError("Cannot instantiate SassNull");
}
}
else {
......
......@@ -47,11 +47,11 @@ namespace SassTypes
NAN_METHOD(Number::SetValue) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsNumber()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a number").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a number");
}
sass_number_set_value(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
......@@ -59,11 +59,11 @@ namespace SassTypes
NAN_METHOD(Number::SetUnit) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsString()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a string").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a string");
}
sass_number_set_unit(unwrap(info.This())->value, create_string(info[0]));
......
......@@ -31,11 +31,11 @@ namespace SassTypes
NAN_METHOD(String::SetValue) {
if (info.Length() != 1) {
return Nan::ThrowTypeError(Nan::New("Expected just one argument").ToLocalChecked());
return Nan::ThrowTypeError("Expected just one argument");
}
if (!info[0]->IsString()) {
return Nan::ThrowTypeError(Nan::New("Supplied value should be a string").ToLocalChecked());
return Nan::ThrowTypeError("Supplied value should be a string");
}
sass_string_set_value(unwrap(info.This())->value, create_string(info[0]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment