diff --git a/src/custom_importer_bridge.cpp b/src/custom_importer_bridge.cpp index ae5be310b..885221999 100644 --- a/src/custom_importer_bridge.cpp +++ b/src/custom_importer_bridge.cpp @@ -16,16 +16,36 @@ SassImportList CustomImporterBridge::post_process_return_value(Handle val for (size_t i = 0; i < array->Length(); ++i) { Local value = array->Get(static_cast(i)); - if (!value->IsObject()) + if (!value->IsObject()) { continue; + } Local object = Local::Cast(value); - char* path = create_string(object->Get(NanNew("file"))); - char* contents = create_string(object->Get(NanNew("contents"))); - imports[i] = sass_make_import_entry(path, (!contents || contents[0] == '\0') ? 0 : strdup(contents), 0); + if (value->IsNativeError()) { + char* message = create_string(object->Get(NanNew("message"))); + + imports[i] = sass_make_import_entry(0, 0, 0); + + sass_import_set_error(imports[i], message, -1, -1); + } + else { + char* path = create_string(object->Get(NanNew("file"))); + char* contents = create_string(object->Get(NanNew("contents"))); + + imports[i] = sass_make_import_entry(path, (!contents || contents[0] == '\0') ? 0 : strdup(contents), 0); + } } } + else if (returned_value->IsNativeError()) { + imports = sass_make_import_list(1); + Local object = Local::Cast(returned_value); + char* message = create_string(object->Get(NanNew("message"))); + + imports[0] = sass_make_import_entry(0, 0, 0); + + sass_import_set_error(imports[0], message, -1, -1); + } else if (returned_value->IsObject()) { imports = sass_make_import_list(1); Local object = Local::Cast(returned_value); @@ -46,7 +66,7 @@ std::vector> CustomImporterBridge::pre_process_args(std::vector> out; for (void* ptr : in) { - out.push_back(NanNew((char const*) ptr)); + out.push_back(NanNew((char const*)ptr)); } return out;