Summary
Starting from API version 63.0, Apex no longer supports JSON serialization of custom exception types and most built-in exceptions. Attempting to serialize an exception, directly or as part of an object now triggers a runtime error:
β
System.JSONException: Type unsupported in JSON: MyException
This change is versioned behavior. In API 62.0 and earlier, exception types could be serialized, but the results were inconsistent and often triggered unexpected serialization errors or missed important fields.
β
Scope
Apex Classes
Apex Triggers (indirectly if exception handling is performed inside methods)
Resources