Compiler Exception Propagation Policy for Nested Error Handling
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing programming languages often lose information about the first exception when a second exception occurs during error handling, making it difficult to diagnose and debug issues, as the first exception is discarded and the second exception is propagated, obscuring the root cause of the problem.
Innovation Solution
A system and method that transforms source code to modify the error propagation policy, allowing the first exception to be propagated and the second exception to be stored, ensuring that both exceptions are handled and their information is retained, using a compiler to configure the transformed code to support multiple exceptions.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If the conventional exception handling policy is applied where a subsequent exception discards a pending exception, then the system can propagate the most recent error quickly, but the root cause information is lost making debugging difficult
Solution Approach 1:
The patent implements a nested exception structure where a primary exception can contain multiple secondary exceptions. When exceptions occur in a cascading manner, each exception is nested within the previous one, creating a hierarchical structure that preserves all exception information while maintaining a clear primary error for propagation. This allows the system to maintain the speed of single exception propagation while preventing information loss through the nested containment of multiple exceptions.
Solution Approach 2:
The patent changes the parameter of exception handling from a single exception model to a multi exception model by modifying the exception data structure to accommodate nested exceptions. This parameter change allows the system to store multiple exception objects within a single exception hierarchy, transforming the information capacity of the exception handling mechanism while maintaining compatibility with existing propagation protocols.
2Ease of operation
If the system propagates only the most recent exception, then the error handling flow remains simple and predictable, but multiple exceptions cannot be tracked simultaneously
Solution Approach 1:
The patent segments the exception information into hierarchical levels with a primary exception representing the most recent error for simple propagation, and secondary exceptions nested within it representing earlier errors. This segmentation allows the system to maintain simple operational interfaces for handling the primary exception while providing access to the full history of exceptions through the nested structure, thus preserving both simplicity and reliability.
Solution Approach 2:
The nested exception structure acts as an intermediary between the simple propagation mechanism and the need for comprehensive error tracking. The primary exception serves as the mediator that is propagated through the system maintaining simplicity, while the nested secondary exceptions preserve additional diagnostic information without disrupting the simple propagation flow.
3Reliability
If a finally block completes abruptly by throwing an exception, then the cleanup process can handle its own errors, but the original exception reason is discarded
Solution Approach 1:
The patent prepares the exception handling mechanism in advance by creating a nested exception structure that can accommodate both the original exception and any exceptions thrown during finally block execution. This preliminary structuring ensures that when the finally block throws an exception, the original exception is already preserved in the nested structure rather than being discarded, thus maintaining reliability while preventing information loss.
Solution Approach 2:
The patent recovers the original exception information that would otherwise be discarded by the conventional policy. By nesting the original exception within the exception hierarchy before the finally block executes, the system ensures that even when the finally block throws a new exception, the original exception is recovered and preserved in the nested structure for later diagnostic purposes.
Data Source
AI summary
A compiler may receive source code including two user source code blocks, each capable of throwing an exception. The received source code may be associated with a policy that discards a pending exception when a subsequent exception occurs. The compiler may transform the source code such that it allows for a propagation policy that supports multiple exceptions. The transformed source code may be executed in an execution environment. Upon execution of the transformed code, a pending exception may be propagated out and a later-in-time exception may be stored.


