Force-Framework

Mark Brennand

AssertionV1

global with sharing class AssertionV1
Description

Class providing programmatic Assertions.

The Salesforce Assert class is great, but it throws an Exception which cannot be caught. So, in reality, is only useful for unit tests.

Ancestor methods should be able to catch assertion errors so they can be handled. For example, the Asynchronous API must be able to catch any assertion failures during the processing of a job so it can record the caught Exception. With the Salesforce assertion Exception, that is not possible.

The APIs in the Force Framework all use this class to check assertions, allowing any Exception to be caught.

Copyright (c) 2025 Mark Brennand, released under MIT License.

AuthorMark Brennand

AssertionV1.AssertionException

global with sharing class AssertionException extends Exception
DescriptionException thrown when an assertion fails.