In Salesforce Apex, System.UnexpectedException is a runtime exception thrown by the Salesforce platform itself when an unexpected internal condition occurs. Unlike most Apex exceptions, System.UnexpectedException cannot be caught with a try/catch block and cannot be thrown manually in Apex code. It is typically associated with a system-level error — also known as a "gack" — and is always accompanied by a descriptive error message.
System.UnexpectedException is thrown by the Salesforce runtime at the platform level and bypasses standard Apex exception handling. It is not a subclass of Exception and cannot be intercepted with try/catch in Apex code. There is no graceful way to handle this exception once it is generated.
Since this exception cannot be caught, the recommended approach is to prevent the conditions that cause it:
System.UnexpectedException is usually self-descriptive and points to the root cause (for example, a null pointer, a configuration issue, or a limit violation).A "gack" is an internal error report automatically generated and logged by Salesforce when an unexpected server-side exception occurs. Gack codes are used by Salesforce Engineering and Support to trace the root cause of platform-level errors. If you see a gack code in your exception message, open a Salesforce Support case and include the gack code.
What is a Gack?
000387856

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.