-
Notifications
You must be signed in to change notification settings - Fork 83
Closed as not planned
Closed as not planned
Copy link
Labels
more information requiredIssue requires more information or a response from the customerIssue requires more information or a response from the customerstalevalidatedVersion information for this issue has been validatedVersion information for this issue has been validated
Description
Summary
When I write an Apex script, I often get cryptic errors like
Error: Line: 118, Column: 1
Error: Unexpected token 'private'.
I would like to have the same error as in class compile
Missing ';' at 'newContact.MailingCountry' (135:9)
Steps To Reproduce
- Paste this example code into the apex script. And try to run it.
// (...) some code above to create the account.
private static Contact createTestContact(Account acc) { // Line 118
Contact newContact = new Contact();
newContact.Academic_Title__c = 'Dr.';
newContact.AccountId = acc.Id;
newContact.Email = '[email protected]';
newContact.FirstName = 'Bob';
newContact.GenderIdentity = 'Male';
newContact.LastName = testContactLastName;
newContact.Phone = '+49012345678';
newContact.MailingStreet = 'Teststreet 58';
newContact.MailingCity = 'TestCity';
newContact.MailingPostalCode = '12-345' // Line 129, mising semicolon here
newContact.MailingCountry = 'Germany';
insert newContact;
return newContact;
}
That gives an error:
Error: Line: 118, Column: 1
Error: Unexpected token 'private'.
Which is completely misleading. It points to the other line, and the error message is useless.
- Paste the same code into the apex class and try to save it.
You will get an error:
Missing ';' at 'newContact.MailingCountry' (135:9)
Now I know what is going on.
Expected result
I am getting the same informative error message in the Apex script.
Actual result
I am getting a misleading error message.
Additional information
System Information
{
"architecture": "win32-x64",
"cliVersion": "@salesforce/cli/2.108.6",
"nodeVersion": "node-v22.20.0",
"osVersion": "Windows_NT 10.0.26100",
"rootPath": "C:\\Users\\####\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\cli",
"shell": "powershell",
"pluginVersions": [
"@oclif/plugin-autocomplete 3.2.35 (core)",
"@oclif/plugin-commands 4.1.33 (core)",
"@oclif/plugin-help 6.2.33 (core)",
"@oclif/plugin-not-found 3.2.68 (core)",
"@oclif/plugin-plugins 5.4.47 (core)",
"@oclif/plugin-search 1.2.31 (core)",
"@oclif/plugin-update 4.7.7 (core)",
"@oclif/plugin-version 2.2.33 (core)",
"@oclif/plugin-warn-if-update-available 3.1.48 (core)",
"@oclif/plugin-which 3.2.40 (core)",
"@salesforce/cli 2.108.6 (core)",
"agent 1.24.13 (core)",
"apex 3.8.1 (core)",
"api 1.3.3 (core)",
"auth 3.9.8 (core)",
"code-analyzer 5.5.0 (user) published 21 days ago (Tue Sep 30 2025)",
"data 4.0.57 (core)",
"deploy-retrieve 3.23.3 (core)",
"info 3.4.88 (core)",
"lightning-dev 4.5.2 (user) published 9 days ago (Mon Oct 13 2025)",
"limits 3.3.67 (core)",
"marketplace 1.3.8 (core)",
"org 5.9.30 (core)",
"packaging 2.20.5 (core)",
"schema 3.3.82 (core)",
"settings 2.4.48 (core)",
"sobject 1.4.73 (core)",
"telemetry 3.6.57 (core)",
"templates 56.3.65 (core)",
"trust 3.7.113 (core)",
"user 3.6.38 (core)",
"@salesforce/sfdx-scanner 4.12.0 (user) published 175 days ago (Tue Apr 29 2025)",
"sfdmu 4.38.0 (user) published 297 days ago (Sun Dec 29 2024)",
"sfdx-git-delta 6.22.0 (user) published 12 days ago (Thu Oct 09 2025) (latest is 6.23.0)"
]
}Metadata
Metadata
Assignees
Labels
more information requiredIssue requires more information or a response from the customerIssue requires more information or a response from the customerstalevalidatedVersion information for this issue has been validatedVersion information for this issue has been validated