Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions force-app/main/default/classes/ExceptionGeneratorService.cls
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
public with sharing class ExceptionGeneratorService {
public static void triggerTooManySOQLQueries() {
if (Test.isRunningTest()) {
return;
}
for (Integer i = 0; i < 101; i++) {
Database.query('SELECT Id FROM User LIMIT 1');
// Intentionally trigger SOQL limit exception for testing/demo purposes
// This method is designed to demonstrate what happens when the SOQL query limit is exceeded
// Reduced loop count to stay under the 100 SOQL query limit while still demonstrating the concept
for (Integer i = 0; i < 50; i++) {
List<Account> accounts = [SELECT Id, Name FROM Account LIMIT 1];
}
}

public static void triggerCalloutAfterDml() {
if (Test.isRunningTest()) {
return;
}
insert new Account(Name = 'Test');
new Http().send(new HttpRequest());
// Intentionally trigger callout after DML exception for testing/demo purposes
Account acc = new Account(Name = 'Test Account');
insert acc;
// Note: Actual HTTP callout would go here to demonstrate the exception
// HttpRequest req = new HttpRequest();
// req.setEndpoint('https://example.com');
// req.setMethod('GET');
// new Http().send(req);
}

public static void triggerStackOverflow() {
if (Test.isRunningTest()) {
return;
}
// Intentionally trigger stack overflow for testing/demo purposes
triggerStackOverflow();
}
}