diff --git a/src/vscode_plugin/package.json b/src/vscode_plugin/package.json index a4f5456e2f2a910806a9371a76541754f624da46..d20723e5e0c712fb5364bc8a14df3d6d03f94307 100644 --- a/src/vscode_plugin/package.json +++ b/src/vscode_plugin/package.json @@ -139,6 +139,15 @@ { "language": "cpp", "path": "./snippets/napi_variable_snippets.json" + }, + { + "language": "cpp", + "path": "./snippets/napi_external_snippets.json" + }, + { + "language": "cpp", + "path": "./snippets/napi_error_snippets.json" + }, } ] }, diff --git a/src/vscode_plugin/snippets/napi_error_snippets.json b/src/vscode_plugin/snippets/napi_error_snippets.json new file mode 100644 index 0000000000000000000000000000000000000000..25fd038c1b4b6d5029fd8508f9868ab6d191c585 --- /dev/null +++ b/src/vscode_plugin/snippets/napi_error_snippets.json @@ -0,0 +1,19 @@ +{ + "Napi get last error info ": { + "prefix": "napigetlasterrorinfo", + "body": [ + "// Retrieve detailed information about the last N-API error that occurred in the given environment.", + "const napi_extended_error_info* errorInfo;", + "napi_get_last_error_info(env, &errorInfo);" + ] + }, + "Napi throw error ": { + "prefix": "napithrowerror", + "body": [ + "// Create and throw a JavaScript Error with a specified code and message.", + "const char* code = \"ERROR_CODE\";", + "const char* msg = \"error message.\";", + "napi_throw_error(env, code, msg);" + ] + } +} \ No newline at end of file