A VS Code extension that generates custom syntax error codes with contextual acronyms and flexible configurations.
- Contextual code generation: Analyzes line content to generate specific acronyms for syntax errors
- Codes with parentheses: Format
(ACRONYM-SUFFIX)
for better readability - Intelligent analysis: Detects keywords like "user", "database", "validation" etc.
- Flexible configuration: Customize default acronym, separator, and suffix length
- Unique context: Generates unique codes based on cursor location in file
- Keyboard shortcuts: Use
Ctrl+Shift+E
(Windows/Linux) orCmd+Shift+E
(Mac) to generate codes quickly
- Position the cursor on the line where you want to insert the code
- Press
Ctrl+Shift+E
(Windows/Linux) orCmd+Shift+E
(Mac) - The code will be automatically inserted at the cursor location
The extension analyzes the line content to determine the most appropriate acronym:
- Line with "user not found" →
(USR-1678A4)
- Line with "database connection failed" →
(DB-A4F2B9)
- Line with "validation error" →
(VAL-B9C1D5)
- Line without specific keywords →
(ERR-D5E3F7)
- Open the command palette (
Ctrl+Shift+P
orCmd+Shift+P
) - Type "Configure Syntax Error Code Generator"
- Follow the instructions to configure:
- Default acronym: The prefix when there's no specific context (e.g., ERR)
- Suffix length: Number of characters after the acronym (1-10)
- Separator: Character between acronym and suffix (e.g., -)
- Use context: Whether to generate unique codes based on location
- Contextual analysis: Whether to analyze the line to automatically determine the acronym
The extension analyzes the line content to determine the most appropriate acronym:
// throw new Error('User not found'); → (USR-1678A4)
// database.query('SELECT * FROM users') → (DB-A4F2B9)
// validateEmail(email) → (VAL-B9C1D5)
// file.upload() → (FILE-C5D2E8)
// api.request() → (NET-D7E4F1)
// config.load() → (CFG-E8F5A2)
// throw new Error('Something went wrong') → (ERR-F9G6B3)
The extension always uses the configured default acronym (ERR):
// throw new Error('User not found'); → (ERR-1678A4)
// database.query('SELECT * FROM users') → (ERR-A4F2B9)
// validateEmail(email) → (ERR-B9C1D5)
// file.upload() → (ERR-C5D2E8)
// api.request() → (ERR-D7E4F1)
// config.load() → (ERR-E8F5A2)
// throw new Error('Something went wrong') → (ERR-F9G6B3)
// Any line → (ERR-XXXXXX)
Note: When contextual analysis is disabled, all error codes use the default acronym established during configuration.
The extension automatically recognizes these keywords:
Keyword | Acronym | Example |
---|---|---|
user, users, login, "not found" | USR | (USR-1678A4) |
authentication, auth, password | AUTH | (AUTH-A4F2B9) |
permission, permissions, access | PERM | (PERM-B9C1D5) |
database, db, query, connection | DB | (DB-C5D2E8) |
file, files, upload, download | FILE | (FILE-D7E4F1) |
validation, validate, input, email | VAL | (VAL-E8F5A2) |
network, http, api, request | NET | (NET-F9G6B3) |
config, configuration, setting | CFG | (CFG-G0H7C4) |
error, exception, failed | ERR | (ERR-H1I8D5) |
The extension can be configured through VS Code settings:
{
"errorCodeGenerator.acronym": "ERR",
"errorCodeGenerator.suffixLength": 6,
"errorCodeGenerator.separator": "-",
"errorCodeGenerator.useContext": true,
"errorCodeGenerator.useContextualAnalysis": true
}
acronym
: Default acronym for error codes (default: "ERR")suffixLength
: Number of characters after the acronym (1-10, default: 6)separator
: Separator between acronym and code (default: "-")useContext
: Whether to include context based on current file (default: true)useContextualAnalysis
: Whether to analyze the line to automatically determine the acronym (default: true)
// throw new Error('User not found'); → (USR-1678A4)
// if (!user) throw new Error('User not found'); → (USR-1678A4)
// database.query('SELECT * FROM users') → (DB-A4F2B9)
// validateEmail(email) → (VAL-B9C1D5)
// file.upload() → (FILE-C5D2E8)
// api.request() → (NET-D7E4F1)
// config.load() → (CFG-E8F5A2)
// throw new Error('Something went wrong') → (ERR-F9G6B3)
// throw new Error('User not found'); → (ERR-1678A4)
// database.query('SELECT * FROM users') → (ERR-A4F2B9)
// validateEmail(email) → (ERR-B9C1D5)
// Any line → (ERR-XXXXXX)
syntax-error-code-generator.generateCode
: Generate and insert a syntax error codesyntax-error-code-generator.configureSettings
: Open the configuration assistant
Ctrl+Shift+E
(Windows/Linux) /Cmd+Shift+E
(Mac): Generate syntax error code
- The extension reads the line where the cursor is positioned
- Searches for predefined keywords in the line
- Determines the most appropriate acronym based on context
- If no specific keywords are found, uses the default acronym
When useContext
is enabled, the extension generates unique codes based on:
- Current file name
- Cursor line and column
- This ensures the same location always generates the same code
When useContext
is disabled, the extension generates random codes using:
- Uppercase letters (A-Z)
- Numbers (0-9)
- Configurable length
- Reload VS Code:
Cmd+Shift+P
→ "Developer: Reload Window" - Check if it's installed:
Cmd+Shift+P
→ "Extensions: Show Installed Extensions"
- Use the correct command:
syntax-error-code-generator.generateCode
- Or use the keyboard shortcut:
Cmd+Shift+E
- Make sure you're in an active text editor
- Try reloading VS Code
- Check if the line contains recognized keywords
- Position the cursor on the line that contains the desired context
- Node.js
- npm
npm install
npm run compile
- Press
F5
in VS Code - A new VS Code window will open with the extension loaded
npm test
This project is licensed under the MIT License.
- Acronym:
ERR
- Separator:
-
- Length:
6
- Result:
(ERR-A4F2B9)