Abnormality processing method and device, equipment, computer storage medium and program product

By setting the starting state point at the starting position of the target method of the target application and capturing global exception information during the application operation, combining preset analysis strategies to identify the exceptions to solve categories and restore the application status, the problem of inefficient exception handling in the existing technology is solved, improving user experience and reducing code complexity and maintenance costs.

CN119576648APending Publication Date: 2025-03-07CHINA UNIONPAY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411708649.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-07

Smart Images

  • Figure CN119576648A_ABST
    Figure CN119576648A_ABST
Patent Text Reader

Abstract

The invention discloses an exception handling method and device, equipment, a computer storage medium and a program product. The exception handling method comprises the steps that in the running process of a target application, global exception information of the target application is captured, and a corresponding initial state point is preset at the initial position of a target method of the target application; analyzing the exception information based on a preset analysis strategy, and identifying a corresponding exception solution category; taking the initial state point of the initial position of the target method corresponding to the abnormal information as a target initial state point under the condition that the abnormal information is the state recoverable type; and the running state of the target application is recovered by using the state data recorded by the target initial state point, so that the exception is efficiently processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data processing, and in particular, relates to an exception handling method, device, equipment, computer storage medium and program product. Background Art

[0002] With the development of computer technology, various application functions are becoming increasingly complex, and the handling of application exceptions is becoming more and more important. At present, exception monitoring code such as try-catch statements are usually wrapped around application code that may throw exceptions, to capture exceptions during code runtime, and to record error logs based on the captured exceptions for subsequent exception analysis and debugging, so that the application can run normally in the future. However, this method not only increases code complexity and high code maintenance costs, but also has low exception handling efficiency, resulting in poor user experience.

[0003] In view of this, how to efficiently handle exceptions when exceptions occur in applications has become an important issue that needs to be solved urgently. Summary of the invention

[0004] The embodiments of the present application provide an exception handling method, apparatus, device, computer storage medium, and program product, which can efficiently handle exceptions when exceptions occur and improve user experience.

[0005] In a first aspect, an embodiment of the present application provides an exception handling method, comprising: during the operation of a target application, capturing global exception information of the target application, wherein the starting position of a target method of the target application is pre-set with a corresponding starting state point, and the starting state point is used to record the state data of the target application before the corresponding target method is executed; based on a preset analysis strategy, analyzing the exception information, and identifying the exception resolution category corresponding to the exception information; when the exception resolution category is a state-recoverable category, using the starting state point of the starting position of the target method corresponding to the exception information as the target starting state point; and using the state data recorded at the target starting state point to restore the running state of the target application.

[0006] In a second aspect, an embodiment of the present application provides an exception handling device, the device comprising: an exception capture module, for capturing global exception information of a target application during the operation of the target application, wherein the starting position of a target method of the target application is pre-set with a corresponding starting state point, and the starting state point is used to record the state data of the target application before the corresponding target method is executed; an exception analysis module, for analyzing the exception information based on a preset analysis strategy, and identifying the exception resolution category corresponding to the exception information; a state determination module, for, when the exception resolution category is a state-recoverable category, using the starting state point of the starting position of the target method corresponding to the exception information as a target starting state point; and a state recovery module, for restoring the running state of the target application using the state data recorded at the target starting state point.

[0007] In a third aspect, an embodiment of the present application provides an exception handling device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the exception handling method as described in the embodiment of the first aspect of the present application is implemented.

[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the exception handling method as described in the embodiment of the first aspect of the present application is implemented.

[0009] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the exception handling method as described in the embodiment of the first aspect of the present application.

[0010] An embodiment of the present application provides an exception handling method. Before the target application runs, the method sets a corresponding starting state point at the starting position of the target method of the target application, wherein the starting state point is used to record the state data of the target application before the corresponding target method is executed. In this way, when an exception occurs in the subsequent target application running, the starting state point can accurately record the state before the target method is executed. In addition, during the running of the target application, the method captures the global exception information of the target application, realizes comprehensive monitoring of the exception, and then analyzes the exception information based on a preset analysis strategy to identify the exception resolution category corresponding to the exception information. The fully monitored exceptions can be classified more accurately, so that in the subsequent accurate determination that the exception resolution category is a state-recoverable category, the starting state point of the starting position of the target method corresponding to the exception information is used as the target starting state point, and the state data recorded by the target starting state point is used to restore the running state of the target application, thereby realizing efficient handling of the exception.

[0011] Furthermore, when the exception resolution category is a state that cannot be recovered, the method will close the process related to the exception information based on a preset exit strategy, thereby actively and orderly closing the related processes, ensuring that the user can experience a smooth exit process and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0013] Figure 1 It is a schematic diagram of an application scenario of the exception handling method provided in an embodiment of the present application;

[0014] Figure 2 It is a schematic diagram of another application scenario of the exception handling method provided in the embodiment of the present application;

[0015] Figure 3 It is a flowchart of an exception handling method provided by an embodiment of the first aspect of the present application;

[0016] Figure 4 is a schematic diagram of abnormal analysis provided in an embodiment of the present application;

[0017] Figure 5 It is a schematic diagram of the system architecture provided by the embodiment of the present application;

[0018] Figure 6 It is a flowchart of an exception handling method provided by another embodiment of the first aspect of the present application;

[0019] Figure 7 It is a flowchart of an exception handling method provided by yet another embodiment of the first aspect of the present application;

[0020] Figure 8 It is a state recovery schematic diagram provided in an embodiment of the present application;

[0021] Fig. 9 It is a structural schematic diagram of an exception handling device provided by an embodiment of the second aspect of the present application;

[0022] Fig.10 It is a structural diagram of an exception handling device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0023] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are intended only to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by showing examples of the present application. It should be noted that the acquisition, storage, use, and processing of information and data in the embodiments of the present application are authorized by users or relevant agencies, in compliance with the relevant provisions of national laws and regulations.

[0024] At present, in order to deal with abnormal situations in applications, exception monitoring codes such as try-catch statements are usually wrapped around application codes that may throw exceptions, exceptions during code execution are captured, and error logs are recorded based on the captured exceptions for subsequent exception analysis and debugging, so that the application can run normally in the future. However, this method not only increases code complexity and high code maintenance costs, but also has low exception handling efficiency, resulting in poor user experience.

[0025] In view of this, the present application provides an exception handling method, which sets a corresponding starting state point at the starting position of a target method of a target application before the target application runs, wherein the starting state point is used to record the state data of the target application before the corresponding target method is executed. In this way, when an exception occurs in the subsequent target application running, the starting state point can accurately record the state before the target method is executed, laying a foundation; and, during the running of the target application, the method captures the global exception information of the target application, realizes comprehensive monitoring of the exception, and then analyzes the exception information based on a preset analysis strategy to identify the exception resolution category corresponding to the exception information, so as to more accurately classify the fully monitored exceptions, so that in the subsequent accurate determination that the exception resolution category is a state-recoverable category, the starting state point of the starting position of the target method corresponding to the exception information is used as the target starting state point, and the state data recorded by the target starting state point is used to restore the running state of the target application, thereby realizing efficient handling of the exception.

[0026] The exception handling method provided in the embodiment of the present application can be used to handle exceptions of various applications, such as: handling exceptions of calling SDK methods in Web-based applications (such as applets), handling exceptions of any method in native applications, handling exceptions of any method in online applications, etc. The exception handling method provided in the embodiment of the present application can be applied to user terminals, and can also be implemented through the cooperation of user terminals and exception handling platforms, which is not limited in the present application. Below, two possible application scenarios of the exception handling method provided in the embodiment of the present application are exemplarily described.

[0027] Figure 1 A schematic diagram of an example of an application scenario of the exception handling method provided in an embodiment of the present application. Figure 1 As shown, the exception handling method provided in the embodiment of the present application is applied to the user terminal 10.

[0028] The user terminal 10 has at least one application, and at least one application has at least one method. The same user terminal may have multiple different applications. The target application in the embodiment of the present application may be any one or more applications in the user terminal 10, and the target method may be any one or more methods in the target application. When the target application is running, the target method in the target application is executed according to the logic of the code. The user terminal 10 can be a mobile phone, a tablet computer, an electronic computer, a smart wearable device, etc., which is not limited here. The target application can be a mini-program, a native application, an online application, etc. The target method in the target application can be a method of calling an SDK, a method of calling some plug-ins, and so on.

[0029] Before the target application is run, for example, during the compilation phase, the user terminal 10 pre-sets a corresponding starting state point at the start position of the target method, and optionally, a corresponding ending state point at the end position of the target method. The starting state point is used to record the state data of the target application before the corresponding target method is executed, and the ending state point is used to record the state data of the target application after the corresponding target method is executed. The state data recorded by the starting state point and the ending state point can be stored in the user terminal 10. For example: Figure 1As shown, the starting position of target method 1 sets the starting state point 1, and the ending state point 1 is set at the ending position. The same is true for target method 2, which will not be repeated here. On this basis, the user terminal 10 can capture the global exception information of the target application during the operation of the target application, analyze the exception information based on the preset analysis strategy, identify the exception resolution category corresponding to the exception information, and when the exception resolution category is a state-recoverable category, the starting state point of the starting position of the target method corresponding to the exception information is used as the target starting state point, and the running state of the target application is restored using the state data recorded at the target starting state point. Optionally, the target ending state point can be determined from the ending state point before the execution of the target method corresponding to the exception information, and the starting state point of the starting position of the target method corresponding to the exception information is used as the target starting state point. Using the state data recorded by the target starting state point and the target ending state point, the running state of the target application is restored to the state corresponding to the target ending state point.

[0030] In the possible system architecture of the first embodiment of the present application, the processing steps of capturing and analyzing the exception information can be executed by the global exception management component set in the process, and the processing steps of state recovery can be executed by the state rollback component set in the independent sub-process. Of course, in actual application, the exception handling method provided in the embodiment of the present application can also be implemented through other forms of system architecture, and the present application does not limit this.

[0031] In other embodiments, when the exception handling method provided in the embodiments of the present application is applied to the user terminal 10, it is implemented through the cooperation between the user terminal and the exception handling platform. Figure 2 A schematic diagram of another example of an application scenario of the exception handling method provided in an embodiment of the present application. Figure 2 As shown, the exception handling method provided in the embodiment of the present application is applied to the user terminal 10, and the user terminal 10 can communicate and interact with the exception handling platform 20.

[0032] The exception handling platform 20 is used to store status data, analyze exception information to identify exception resolution categories, and may include more than one electronic device. Electronic devices may include servers, gateways, routers and other devices, and the types and quantities of electronic devices in the exception handling platform 20 are not limited here. Different target applications can open corresponding accounts on the exception handling platform 20, and the user terminal 10 can upload the status data recorded at the starting state point to the account corresponding to the exception handling platform 20 for storage. Optionally, the status data recorded at the end state point can also be uploaded together. The user terminal 10 can also send the captured exception information to the exception handling platform 20, and use the exception handling platform 20 to identify the exception resolution category. When it is determined to be a recoverable state category, the exception handling platform 20 will send the relevant status data to the user terminal 10 so that the user terminal 10 can restore the running state of the target application.

[0033] It can be seen from the above application scenarios that the method provided in the embodiments of the present application can accurately and comprehensively monitor exceptions and identify exception resolution categories, so that subsequently, when the exception resolution category is a state-recoverable category, the starting state point of the target method starting position corresponding to the exception information can be used as the target starting state point, and the state data recorded at the target starting state point can be used to restore the running state of the target application, thereby achieving efficient handling of exceptions.

[0034] The exception handling method, apparatus, device, computer storage medium and program product in the present application are described below respectively.

[0035] A first aspect of the present application provides an exception handling method that can be executed by a user terminal. Figure 3 This is a flowchart of an exception handling method provided in an embodiment of the first aspect of the present application. Figure 3 As shown, the exception handling method may include steps 310 to 340.

[0036] Step 310: During the operation of the target application, global exception information of the target application is captured.

[0037] The starting position of the target method of the target application is pre-set with a corresponding starting state point, and the starting state point is used to record the state data of the target application before the corresponding target method is executed.

[0038] Optionally, the end position of the target method is pre-set with a corresponding end status point, and the end status point is used to record the state data of the target application after the corresponding target method is executed.

[0039] The target application can be understood as a program used to perform tasks or services, such as mini-programs, native applications, online applications, etc.

[0040] The target method can be understood as any one or more methods in the target application. A method is a set of instructions used to perform operations or calculations, which can be called by an object to perform tasks. For example, the target method can be expressed as a method that calls an SDK, a method that calls any plug-in, and so on.

[0041] In some embodiments of the present application, a start state point may be inserted during the compilation phase of the target application, in some embodiments an end state point may also be inserted, and in other embodiments of the present application, a start state point and an end state point may be inserted into a source code file.

[0042] In some embodiments of the present application, the state data may include at least one of: state data of an interface element, state data of a database transaction, a file system operation snapshot, and state data of a network request response. The method further includes:

[0043] The state data recorded at the start state point and / or the end state point is acquired and saved through a first sub-process, where the first sub-process is a sub-process created separately from a process created for the target application.

[0044] The state data of the interface elements is data used to describe the state of each interface element in the interface. Exemplarily, the state data of the interface elements may include, but is not limited to: element information of the interface elements, used to indicate which interface elements are present, whether the interface elements are visible, whether the interface elements are selected, focus status, etc. The state data of the interface elements can be used to restore the interface state of the target application.

[0045] The status data of a database transaction is data used to describe the status of a database transaction. Exemplarily, the status data of a database transaction may include, but is not limited to, the identification of a database transaction, whether the database transaction has been started, whether it has been suspended, whether it has been committed, etc. The integrity and consistency of a database transaction can be ensured through the status data of a database transaction.

[0046] A file system operation snapshot is a copy of the file system at a certain point in time. The snapshot records the status of all files and directories in the file system, including but not limited to file content, metadata (such as permissions, timestamps, etc.) and directory structure. Through the file system operation snapshot, application data can be reloaded.

[0047] The status data of the network request response is data used to describe the status of the network request response. Exemplarily, the status data of the network request response may include, but is not limited to: network request identification, HTTP status code, response header, response body and other relevant information, through which the processing result of the network request and the status of the server can be confirmed. The network request identification is an identifier used to uniquely identify the network request. By obtaining the network request identification, the correct matching of the request and the response can be ensured, and the reliability and maintainability of the system can be improved.

[0048] In this embodiment, the first sub-process obtains and saves the status data recorded by the starting status point and / or the ending status point, and the first sub-process is a sub-process created separately from the process created for the target application. Therefore, the first sub-process will not cause blocking and waiting for the main process of the target application, thereby improving the stability of the target application.

[0049] Exemplarily, the status data recorded at the starting status point may include, but is not limited to, UI (User Interface) element information, database transaction ID (Identifier), snapshot of file system operations, serial number and response status of network requests, and other status data.

[0050] The status data recorded at the end status point may include, but is not limited to, the final status of a database transaction, the final result of a file system operation, the final response of a network request, and other status data.

[0051] In order to improve the efficiency of setting the start state point and the end state point, in some embodiments of the present application, before step 310, the following steps are further included:

[0052] During the target application compilation phase, the methods in the target application are traversed, a corresponding starting state point is inserted at the beginning of the code of the traversed method, and a corresponding ending state point is inserted at the end of the traversed method, and the target method is the traversed method.

[0053] In some embodiments, during the compilation phase of the target application, the compiler may generate an intermediate representation for the compilation of the target application, and the intermediate representation may be expressed as a file or as a data structure in memory. The intermediate representation is traversed through methods, and the corresponding starting state point is inserted at the starting position of the code of the traversed method, and the corresponding ending state point is inserted at the ending position of the traversed method, so that the intermediate representation includes the starting state point and the ending state point, and then after the compilation is completed, a series of files for running the target application are generated, such as target files, executable files, dynamic library files, etc. This series of files also includes the starting state point and the ending state point to ensure that when the target application runs to the position of the starting state point and the ending state point, the starting state point and the ending state point will record the state of the target application at that time and obtain the state data of the target application.

[0054] For example: based on the Aspect-Oriented Programming (AOP) framework technology, the starting state point and the ending state point of the method in the target application can be inserted when the target application is compiled. Specifically, the methods in the application are traversed during the compilation stage. During the traversal process, the starting state point is inserted before the execution of the target method, and the ending state point is inserted after the execution of the target method, so that the state recovery logic can be implemented through the state data recorded by the starting state point and the ending state point. Aspect-Oriented Programming is a programming paradigm that improves the modularity of the code by separating cross-cutting concerns from business logic. Cross-cutting concerns include starting state points and ending state points.

[0055] For example, Figure 5 As shown in the system architecture diagram, during the compilation phase of the target application, the AOP technology can be used to insert the start state point and the end state point into the target application during the compiler compilation process.

[0056] For example, if the target application includes target method 1, target method 2, and target method 3, the starting state point and the ending state point corresponding to target method 1, target method 2, and target method 3 are respectively set at the starting position and the ending position of the corresponding target method. Among them, the starting position of target method 1 is pre-set with the corresponding starting state point 1, the ending position of target method 1 is pre-set with the corresponding ending state point 1, the starting position of target method 2 is pre-set with the corresponding starting state point 2, and the ending position of target method 2 is pre-set with the corresponding ending state point 2. Among them, the starting state point 1 is used to record the state data of the target application before the corresponding target method 1 is executed; the ending state point 1 is used to record the state data of the target application after the corresponding target method 1 is executed. The status data recorded by the starting state point 2 and the ending state point 2 are similar, and will not be repeated here.

[0057] In the above embodiment, by inserting the start state point and the end state point by traversing the method in the compilation phase, the processing is more efficient compared with the manual insertion method in the source code phase. By inserting the start state point and the end state point, fine control is provided for the operation of the target application, ensuring that it can be quickly and accurately restored to a stable state when an exception occurs.

[0058] Exception information refers to information generated when an exception such as an accident or error occurs during the execution of the target method of the target application, causing the target method to fail to execute correctly, and is used to describe the accident or error. For example, the exception information can be expressed as exception object information, thread information and / or stack trace information.

[0059] The abnormal object information may be expressed as information related to the abnormal object, such as the class or interface to which the abnormal object belongs.

[0060] The thread information may be information related to the abnormal thread, such as the name of the thread or the thread group where the abnormality occurs.

[0061] The stack trace information is a series of call stack information generated when an exception occurs during the execution of the target application. This information can show the location where the exception occurred and the call path before the exception occurred.

[0062] Since different exception object information, thread information, and stack trace information usually represent different types of errors or exceptions, and can also provide the context in which the exception occurred and determine the impact, capturing the exception object information, thread information, and stack trace information can subsequently enable a more accurate analysis of the exception information.

[0063] There are many specific implementation methods for capturing global exception information of the target application during the running process of the target application. For example, a global exception management component can be deployed in the process of the target application to capture global exception information of the target application. For another example, the global exception information of the target application can be captured by calling some middleware.

[0064] In order to more comprehensively capture exceptions in the operation of the target application, in some embodiments of the present application, in step 310, capturing global exception information of the target application during the operation of the target application includes:

[0065] The global exception information of the target application is captured by a global exception management component set in one or more processes in which the target application is running.

[0066] A process is the basic unit for resource allocation and scheduling in an operating system. When a target application is started, the operating system creates a process for the target application, and the process contains information such as the code, data, stack, and register status of the target application. When an exception occurs in the program, the process also contains corresponding exception information. In an embodiment of the present application, if an exception occurs in the target application, the process in which the target application is running will contain the exception information of the target application, so that the embodiment of the present application can capture the global exception information of the target application in the process by deploying a global exception management component.

[0067] Exemplarily, the global exception management component can be deployed in each independent process, which includes processing logic for capturing and analyzing exception information according to predefined rules, and is responsible for capturing the global exception information of the target application and analyzing it to identify the exception resolution category. Furthermore, the global exception management component can also report the captured exception information to the relevant user, server or terminal device for exception resolution, so that the user or other relevant personnel can track and resolve the exception processing.

[0068] Step 320: Based on a preset analysis strategy, the exception information is analyzed to identify the exception resolution category corresponding to the exception information.

[0069] The preset analysis strategy may include analysis of multiple dimensions of abnormal information. For example, the preset analysis strategy may include at least one of the analyses of multiple dimensions of abnormal type analysis, abnormal context analysis, and abnormal impact analysis. The implementation method of the preset analysis strategy is not limited. For example: based on the multiple dimensions to be analyzed, the preset analysis strategy may include predefined abnormal information analysis rules, which are used to identify the abnormal solution category corresponding to the abnormal information by rule matching. For another example, based on the multiple dimensions to be analyzed, the preset analysis strategy may be expressed as a trained machine learning model, which uses the abnormal solution pattern pre-learned by the machine learning model to identify the abnormal solution category corresponding to the abnormal information. For example, the machine learning model can be trained using a training data set containing abnormal information samples and abnormal solution category labels. The machine learning model may include any machine learning model such as a convolutional neural network model and a recurrent neural network model.

[0070] The exception resolution category is a category used to classify different exception resolution strategies. In the embodiment of the present application, the identified exception resolution category can be a state-recoverable category or a state-unrecoverable category. The state-recoverable category is used to characterize the category of an exception resolution strategy that can restore the state of the target application to a stable state by means of state rollback, etc. The state-unrecoverable category is used to characterize the category of another exception resolution strategy corresponding to the case where the state of the target application cannot be restored to a stable state.

[0071] In some embodiments of the present application, step 320 may be performed by a global exception management component deployed in the process.

[0072] In some embodiments of the present application, the abnormal information of the state cannot be recovered can be identified first, and then the abnormal information not identified as the state cannot be recovered can be regarded as the state recoverable category, and the state recovery can be attempted. Specifically, the abnormal information is analyzed based on the preset analysis strategy to identify the abnormal solution category corresponding to the abnormal information, including:

[0073] Based on a preset analysis strategy, at least one of an abnormality type analysis, an abnormality context analysis, and an abnormality impact analysis is performed on the abnormal information to determine whether the abnormality resolution category corresponding to the abnormal information is a status unrecoverable category;

[0074] In the case that the abnormal information does not correspond to the status cannot be recovered category, it is determined that the abnormality resolution category corresponding to the abnormal information is the status can be recovered category.

[0075] In this embodiment, anomalies are analyzed and classified from one or more dimensions of anomaly type analysis, anomaly context analysis, and anomaly impact analysis based on a preset analysis strategy, so that the anomaly resolution category can be identified more accurately and the anomaly resolution strategy can be selected accurately and flexibly.

[0076] For example, Figure 4 As shown in the exception analysis diagram, the exception information may include exception object information, thread information and / or stack trace information; the exception analysis may include exception type analysis, exception context analysis and exception impact analysis; by performing exception analysis on the exception information of this exemplary embodiment, it is possible to accurately and comprehensively identify exceptions in the category of unrecoverable state and exceptions in the category of recoverable state.

[0077] Among them, the abnormality type analysis refers to the analysis method of determining whether the abnormality is unrecoverable based on the type of abnormality. Since the type of abnormality usually characterizes the related methods or system components involved in the abnormality, if the related methods or system components involved in the abnormality are relatively critical and have a significant impact on the overall operation of the system, the state cannot be recovered. For example: if the abnormality information is determined to be a system-level abnormality through abnormality type analysis, it indicates that the abnormality is related to the operation of the system and involves the underlying operating system, hardware or infrastructure. At this time, it can be determined that the abnormality is an abnormality that cannot be recovered.

[0078] Exception context analysis refers to the collection and analysis of context information related to the exception information to determine whether the specific cause and environment of the exception indicates that the state cannot be recovered. For example, the context information related to the exception information can be collected and analyzed to determine whether the context information indicates that the state cannot be recovered. The context information usually represents the methods, components, resources, etc. involved in the exception. If these methods, components, resources, etc. are critical, the state cannot be recovered, otherwise the state can be recovered. For example: if the context information related to the exception information is the key information marked by the code annotation, it is determined that the exception is an exception that cannot be recovered.

[0079] Abnormal impact analysis refers to an analysis method that determines whether an abnormality is unrecoverable based on the degree of impact of the abnormality on the system, business and / or users. For example, if the abnormal information is related to certain key operations and / or key components, and these key operations and / or key components have a significant impact on the overall operation of the system, business and / or users, then the abnormality is an abnormality that cannot be recovered. For example, transaction operations such as payment and refund are key operations. If the abnormal information is related to these key operations, it is determined that the abnormality is an abnormality that cannot be recovered.

[0080] For example, if the exception information captured in step 310 is related to the page viewing operation, through the analysis of step 320, the exception resolution category corresponding to the exception information is not identified as a state that cannot be recovered category, then it can be determined that the exception information is a state that can be recovered category, and then an attempt to recover the state of the exception can be made subsequently.

[0081] For another example, if the exception information captured in step 310 is related to the key method context marked by the code annotation, through the analysis of step 320, the exception resolution category corresponding to the exception information is identified as a state unrecoverable category, and no subsequent state recovery attempt will be made for the exception.

[0082] It is understandable that in some embodiments, when the exception information is obviously a solvable exception, the recoverable status category can be directly identified through the exception information without the need to exclude the unrecoverable category for identification. The embodiments of the present application are not limited to this.

[0083] In order to more accurately exclude the exceptions of the state cannot be recovered category, find out the state recoverable exceptions as comprehensively as possible to try to recover the state, and achieve the purpose of effectively solving the exceptions, in some embodiments of the present application, based on the preset analysis strategy, at least one of the exception type analysis, exception context analysis and exception impact analysis is performed on the exception information to determine whether the exception resolution category corresponding to the exception information is the state cannot be recovered category, including:

[0084] Performing an abnormality type analysis on the abnormal information based on a preset analysis strategy, and in the case where the abnormal information is analyzed to include a system-level abnormality, determining that the state corresponding to the abnormal information cannot be restored;

[0085] Performing an exception context analysis on the exception information based on a preset analysis strategy, and analyzing that context information related to the exception information includes key information marked by a code annotation, determining that the state corresponding to the exception information cannot be restored;

[0086] When the abnormal impact analysis is performed on the abnormal information based on a preset analysis strategy and it is found that the operation related to the abnormal information includes a key operation or a key component marked by a code annotation, it is determined that the state corresponding to the abnormal information is a category that cannot be recovered.

[0087] Among them, system-level exceptions refer to system-level exceptions involving the underlying operating system, hardware, or infrastructure. For example, system-level exceptions can be manifested as OutOfMemoryError, StackOverflowError, and other exceptions.

[0088] The context information related to the exception information may include the point where the exception occurred and / or the system status.

[0089] The exception occurrence point refers to the location where the exception occurs in the target application, which can usually be represented as a method or a component. In this embodiment, if the location where the exception occurs includes key information marked by code annotations, it indicates that the exception belongs to the category of state cannot be recovered and is not suitable for state rollback. Among them, the key information marked by code annotations can include key methods and / or system components in the initialization phase.

[0090] The system state refers to the system operation status when an exception occurs. In this embodiment, if when an exception occurs, the system operation status related to the exception includes the resource usage that needs to be monitored as marked by the code annotation, and the system resource usage exceeds the preset threshold or is performing key maintenance or update operations, then the exception is characterized as a state that cannot be recovered and is not suitable for state rollback.

[0091] Critical operations refer to operations that are marked by code annotations due to their high impact on the system, business and / or users. Whether the impact on the system, business and / or users is high can be determined by the content of the code annotations. For example: transaction operations such as payment and refund, information update, data submission and other user data change operations can be marked as critical operations through specific code annotations that represent high impact. When an exception is related to these critical operations, it indicates that the exception belongs to the category of unrecoverable state and is not suitable for state rollback.

[0092] Key components refer to components that are marked by code annotations due to their high impact on the system, business and / or users. Whether the impact on the system, business and / or users is high can be determined by the content of the code annotations. For example: methods or classes related to database components and cache components are marked as key components through specific code annotations that represent high impact. When an exception is related to these key components, it indicates that the exception belongs to the category of unrecoverable state and is not suitable for state rollback.

[0093] Code annotation refers to annotation data added to the code, which can be used by the compiler, tools or runtime environment to provide additional information. Code annotations can be added during the coding stage according to the specifications agreed upon by the programming language, or they can be added in a customized way. For example: in some programming languages, if the code annotation "@ImportantOP" is added in a customized way, then the operation corresponding to the code marked by the "@ImportantOP" is the critical operation. If the exception is related to the operation corresponding to the code marked by the "@ImportantOP", then the exception belongs to the category of state cannot be recovered and is not suitable for state rollback.

[0094] By using specific code annotations to mark key information, key operations, and key components during the coding phase, it is possible to mark potential abnormal risk points where the status cannot be restored, so as to accurately identify the abnormal resolution category.

[0095] For example, during the coding phase, the following code annotations for methods, components, or operations may be added to the code of the target application:

[0096] Key methods and system components of the initialization phase;

[0097] Methods or classes that need to monitor resource usage;

[0098] Critical operations with a large impact (such as transaction operations, user data change operations, etc.);

[0099] Methods or classes involving database and cache systems.

[0100] By marking the above methods, components or operations as key information, key components or key operations in the form of code annotations, it is possible to accurately identify exceptions whose states cannot be recovered when related exceptions occur.

[0101] In this way, by excluding exceptions that are obviously of the category of unrecoverable state, it is possible to more comprehensively identify exceptions of the category of recoverable state, and to restore the state of the exceptions that can be restored as comprehensively as possible, so that the target application can restore the state.

[0102] Step 330: When the exception resolution category is a state-recoverable category, the starting state point of the target method starting position corresponding to the exception information is used as the target starting state point.

[0103] In some embodiments, the target end state point may also be determined from the end state point before the target method corresponding to the exception information is executed, so that the state data recorded at the target end state point can be used to subsequently restore the state of the target application.

[0104] The state recoverable category refers to an exception resolution method that can restore the state of the target application to a stable state by means of state rollback, etc. Therefore, when the captured exception is of the state recoverable category, in order to perform a state rollback, it is necessary to determine the target end state point from the end state point before the execution of the target method corresponding to the exception information, and use the start state point of the start position of the target method corresponding to the exception information as the target start state point, so that the state of the target application can be rolled back based on the state data recorded at the target start state point and the target end state point.

[0105] Rollback refers to the process of restoring the target application to a previously known stable state.

[0106] The target end state point can be any stable end state point before the target method is executed. For example, the most recent stable end state point before the target method is executed can be taken as the target end state point. In this implementation, the state rollback is faster, the state recovery is easier, and the exception resolution effect is better. It is understandable that in addition to the most recent end state point, taking other stable end state points before the target method is executed can also achieve the purpose of state recovery.

[0107] Continuing with the previous example: if exception information 2 is captured when an exception occurs in the execution of target method 2, the exception resolution category corresponding to exception information 2 is identified as a recoverable state category. Therefore, the target end state point determined from the end state point before the execution of target method 2 can be end state point 1, and the target start state point can be start state point 2.

[0108] Step 340: Using the status data recorded at the target starting status point, restore the running status of the target application.

[0109] Optionally, the state data recorded at the target starting state point may be used to restore the running state of the target application to the state corresponding to the target starting state point.

[0110] Optionally, the state data recorded at the target starting state point and the target ending state point may be used to restore the running state of the target application to the state corresponding to the target ending state point.

[0111] By restoring the running state of the target application to the state corresponding to the target starting state point or the target ending state point, the target application can be adaptively restored to its state when it crashes due to an abnormality. It can be seen that according to the method provided in the embodiment of the present application, the target application can try to recover to a stable state, allowing developers to analyze and locate problems without affecting the normal use of users, thereby significantly reducing the crash rate of the target application when encountering an abnormality, and reducing the impact on the daily use of users, only hindering individual abnormal functions.

[0112] In step 340, the specific implementation method of restoring the target application to the state corresponding to the target end state point is not limited. For example, the state can be restored by state rollback, or by a state machine.

[0113] Exemplarily, in an embodiment of state recovery by state rollback, the processing logic of state rollback can be implemented by a state rollback component. Combined with the aforementioned embodiment of capturing and analyzing exception information based on a global exception management component, the globality and consistency of exception processing can be ensured through the linkage between the global exception management component and the state rollback component, providing a powerful exception management capability for the application. Specifically, in step 310, capturing the global exception information of the target application during the operation of the target application includes:

[0114] The global exception information of the target application is captured by a global exception management component set in the process in which the target application runs.

[0115] Accordingly, the step 320 analyzes the abnormal information based on the preset analysis strategy to identify the abnormality resolution category corresponding to the abnormal information, including:

[0116] The exception information is analyzed through a preset analysis strategy of the global exception management component to identify the exception resolution category corresponding to the exception information.

[0117] Accordingly, the using the state data recorded by the target starting state point and the target ending state point to restore the running state of the target application to the state corresponding to the target ending state point includes:

[0118] Based on the state rollback component set in the process, the running state of the target application is restored using the state data recorded at the target starting state point. Optionally, based on the state rollback component, the running state of the target application can be restored to the state corresponding to the target ending state point using the state data recorded at the target starting state point and the target ending state point.

[0119] For example, Figure 5As shown in the system architecture diagram, the state rollback component can be deployed in the same process as the global exception management component. The global exception management component is responsible for intercepting exceptions and capturing exception information, and reporting the exception information to relevant users or servers. The global exception management component analyzes the exception information (such as context analysis, etc.) and identifies the exception resolution category. Specifically, the exceptions in the category of state cannot be recovered can be identified first, and the exceptions in the category of state cannot be recovered can be excluded, and the exceptions in the category of state can be recovered can be identified. In addition, an exception notification can be pre-registered in the state rollback component. The exception notification is used to trigger the state rollback component to execute the state rollback logic when the global exception management component identifies an exception in the category of state recoverable exception. Through the linkage between the global exception management component and the state rollback component, the globality and consistency of exception handling can be guaranteed, providing a powerful exception management capability for the application.

[0120] The state rollback component is a key component for implementing target application repair. When an exception occurs, the state rollback component can restore the target application to the last stable state point based on the end state point and the start state point before the target method is executed, so that the target application can quickly recover from the exception and continue to run. Exemplarily, the state rollback component can be used for state data preservation, state recovery and user feedback at the start state point and the end state point. User feedback can include error prompts.

[0121] Taking into account that state rollback may involve multiple other components (such as network, database, file system, user interface, etc.), in order to improve the stability of the target application and the consistency of data, in some embodiments of the present application, the state data includes: at least one of the state data of interface elements, state data of database transactions, file system operation snapshots, and state data of network request responses.

[0122] The using the state data recorded by the target starting state point and the target ending state point to restore the running state of the target application to the state corresponding to the target ending state point includes:

[0123] Reconnecting to the database based on the state data of the database transaction recorded at the target start state point and the target end state point;

[0124] Reloading application data based on the file system operation snapshots recorded at the target starting state point and the target ending state point;

[0125] Reestablishing a network connection based on the state data of the network request response recorded at the target starting state point and the target ending state point;

[0126] The interface elements are reset based on the state data of the interface elements recorded at the target starting state point and the target ending state point.

[0127] For example, you can reestablish connections to the database and network, and restore to the stable state before the operation.

[0128] Reloading application data can be understood as a data recovery process. According to the file system operation snapshot, the application data saved in the snapshot can be reloaded to ensure data consistency and integrity.

[0129] Resetting interface elements can be understood as the process of interface recovery. For example, when state recovery involves user interface recovery, the properties of interface elements, such as position, size, selected state, etc., can be reset based on the state data recorded at the start state point and the end state point to reproduce the interface layout and content that the user saw before, ensuring the consistency and usability of the user interface.

[0130] In some embodiments of the present application, for an exception that is state-recoverable, an attempt to recover the state is usually made first. If the attempt fails, the relevant process can be closed based on a preset exit strategy, thereby actively and orderly closing the relevant process to ensure that the user can experience a smooth exit process and improve the user experience. Specifically, after step 340, the method further includes:

[0131] Monitoring whether the running state of the target application is successfully restored to the state corresponding to the target end state point;

[0132] If the state corresponding to the target end state point is not successfully restored, the process related to the abnormal information is closed based on a preset exit strategy.

[0133] There is no limit to the way to monitor whether the recovery is successful, for example, it can be monitored by multiple ways such as whether an error is reported again, whether the data is consistent, whether the user operation can be performed normally, etc. When problems such as a second error, inconsistent data, and user operation failure occur, it can be determined that the state corresponding to the target end point has not been successfully restored. In this case, the relevant process can be closed by the preset exit strategy, so as to achieve the purpose of actively and orderly closing the relevant process.

[0134] It can be seen that according to the exception handling method provided in the embodiment of the present application, before the target application runs, a corresponding starting state point is set at the starting position of the target method of the target application, and a corresponding ending state point is set at the ending position of the target method, wherein the starting state point is used to record the state data of the target application before the corresponding target method is executed, and the ending state point is used to record the state data of the target application after the corresponding target method is executed. In this way, when an exception occurs in the subsequent target application running, the starting state point and the ending state point can accurately record the state before and after the execution of the target method, laying a foundation, and the method captures the global exception information of the target application during the running process of the target application. Comprehensive monitoring of exceptions is achieved, and then based on the preset analysis strategy, the exception information is analyzed to identify the exception resolution category corresponding to the exception information, so that the fully monitored exceptions can be classified more accurately, so that in the subsequent accurate determination of the exception resolution category as a state-recoverable category, the target end state point can be determined from the end state point before the execution of the target method corresponding to the exception information, and the starting state point of the starting position of the target method corresponding to the exception information is used as the target starting state point. The state data recorded by the target starting state point and the target end state point are used to restore the running state of the target application to the state corresponding to the target end state point, thereby achieving efficient handling of exceptions.

[0135] Furthermore, when the exception resolution category is identified as a category where the status cannot be restored, or after attempting to restore the status, if an exception still occurs or other recovery is unsuccessful, the relevant processes are actively and orderly closed based on the preset exit strategy and the user is prompted, thereby achieving the purpose of actively and orderly closing the relevant processes, and providing a friendly user experience.

[0136] Figure 6 This is a flowchart of an exception handling method provided by another embodiment of the first aspect of the present application. Figure 6 As shown, the exception handling method may include steps 310 to 340. Figure 3 The embodiment shown is different in that Figure 6 In the illustrated embodiment, step 3202 is also included.

[0137] Step 3202: When the exception resolution category is a category where the status cannot be recovered, close the process related to the exception information based on a preset exit strategy.

[0138] Optionally, in step 330 of this embodiment, when the exception resolution category is a state-recoverable category, the target end state point is determined from the end state point before the target method corresponding to the exception information is executed, and the starting state point of the starting position of the target method corresponding to the exception information is used as the target starting state point.

[0139] Optionally, in step 340 of this embodiment, the running state of the target application is restored to the state corresponding to the target end state point by using the state data recorded at the target start state point and the target end state point.

[0140] Among them, exceptions in the category of state that cannot be recovered may cause the target application to suddenly crash or freeze if they are not processed. For example, exceptions in the category of state that cannot be recovered may include: system-level exceptions, exceptions occurring in the initialization phase of the application or in key system components, exceptions in an unstable system state, exceptions occurring in key operations involving the integrity of business logic, exceptions affecting key system components, etc. According to the method provided in the embodiment of the present application, actively closing related processes based on a preset exit strategy can enable users to experience a normal process exit and provide a better experience.

[0141] The preset exit strategy is a strategy used to ensure the active and orderly closure of abnormal related processes. The specific content of the strategy can be set according to the specific circumstances of the target application in actual application, and this application does not limit this.

[0142] For example, in some embodiments, the preset exit strategy may include the processing order and processing logic for any one or more aspects such as logging, resource release, data persistence, notification mechanism, cleaning of temporary files and user notification, so as to ensure the stability of the system and the consistency of data when the process is closed.

[0143] For another example, in some embodiments, the preset exit strategy may specifically include:

[0144] Output exit prompt information;

[0145] Saving the abnormal information;

[0146] The process of the target method corresponding to the exception information is closed, and the main process of the target application is started.

[0147] For example, the process closing prompt information can be output through the interface display prompt information or voice broadcast prompt information, so that users can timely understand the current situation of the target application, and the user experience is friendly. When saving exception information, the exception information can be submitted to the exception resolution background for saving. The exception resolution background can be understood as a platform for the operation and maintenance party to analyze and solve exceptions. By outputting prompt information, saving exception information, closing the abnormal process and starting the main process, users can feel that the system is stable and the exception resolution process is orderly, which improves the user experience and the overall service quality.

[0148] It should be noted that this Figure 6 Parts not described in detail in the illustrated embodiments may be referred to Figure 3The relevant descriptions of steps 310 to 340 are not repeated here.

[0149] Furthermore, this embodiment can output process closing prompt information before closing the abnormal related process, so that the user can understand the current situation of the target application in time, bringing a good feeling of orderly program exit.

[0150] When this embodiment identifies an exception of the category where the state cannot be recovered, it closes the exception-related process according to the preset exit strategy, which can significantly reduce the crash rate and avoid an abrupt flash back experience for the user, thereby minimizing the impact on the user; when an exception of the category where the state can be recovered is identified, the state data saved by the state point is used to attempt to restore the state, thereby realizing an exception management solution with adaptive state recovery, effectively improving the efficiency of exception resolution and improving user experience.

[0151] Figure 7 A flowchart of an exception handling method provided by another embodiment of the first aspect of the present application. Figure 7 As shown, the exception handling method may include steps 302 to 340. Figure 3 and Figure 6 The embodiment shown is different in that Figure 7 In the illustrated embodiment, steps 302, 304, 306 and 3201 are also included; Figure 3 and Figure 6 Step 310 in the illustrated embodiment is Figure 7 In the embodiment shown, it is specifically manifested as step 3102 and step 3104. Among them:

[0152] Step 302: In the coding stage, code annotations are added to the code of the target application.

[0153] For example, the added code annotations may include: key methods and system components in the initialization phase; methods or classes that require monitoring of resource usage; key operations with greater impact (such as transaction operations, user data change operations, etc.); methods or classes involving databases and cache systems.

[0154] Step 304: During the compilation phase, a start state point and an end state point are added to the target method in the target application.

[0155] This step can use AOP technology to add starting state points and ending state points by traversing methods.

[0156] Step 306: Deploy a global exception management component in the process where the target application is running.

[0157] The global exception management component includes the processing logic for capturing and analyzing exception information according to predefined rules. It is responsible for capturing and analyzing the global exception information of the target application. For example, the global exception management component can combine the code annotations marked in the coding stage, comprehensively analyze the exception type, context information and other dimensions, and filter out the exceptions of the recoverable state category. The global exception management component can ensure the globality and consistency of exception handling.

[0158] Step 3102: Intercept abnormal events through the global abnormality management component.

[0159] Step 3104: Extract exception information from the exception event through the global exception management component.

[0160] Step 320: Based on a preset analysis strategy, the exception information is analyzed to identify the exception resolution category corresponding to the exception information.

[0161] For example, in step 320, the exception resolution category can be identified by combining code annotations and using a preset analysis strategy through rule matching or the like.

[0162] Step 3201: Determine whether the exception resolution category is a status that cannot be recovered category.

[0163] Step 3202: When the exception resolution category is a status that cannot be recovered category, close the process related to the exception information based on a preset exit strategy.

[0164] If it is not a category where the status cannot be restored, it is determined to be a category where the status can be restored.

[0165] Step 330: When the exception resolution category is a recoverable state category, determine the target end state point from the end state point before the target method corresponding to the exception information is executed, and use the start state point of the start position of the target method corresponding to the exception information as the target start state point.

[0166] Step 340: Using the state data recorded at the target start state point and the target end state point, restore the running state of the target application to the state corresponding to the target end state point.

[0167] It should be noted that this Figure 7 Parts not described in detail in the illustrated embodiments may be referred to Figure 3-Figure 6 The relevant descriptions of steps 310 to 340 are not repeated here.

[0168] In this embodiment, when an exception of the state cannot be recovered category is identified, the exception-related process is closed according to the preset exit strategy, which can significantly reduce the crash rate and avoid an abrupt flash back experience for the user, thereby minimizing the impact on the user; when an exception of the state can be recovered category is identified, the state data saved by the state point is used to attempt to restore the state, thereby realizing an exception management solution with adaptive state recovery, effectively improving the efficiency of exception resolution and improving user experience.

[0169] In order to make the method provided in the embodiment of the present application easier to understand, the following is combined with Figure 8 The state recovery diagram shown is explained in detail. Figure 8 In the illustrated embodiment, the global exception management component and the state rollback component are deployed in process 1 of the target application.

[0170] The global exception management component is used to capture the global exception information of the target application, analyze the exception information, and identify the exception resolution category corresponding to the exception information.

[0171] For example: In actual applications, the global exception management component can be implemented based on the global exception handler Thread.UncaughtExceptionHandler.

[0172] Furthermore, the global exception management component can also be used to record error information in a log and / or report the error to relevant users, servers and / or terminal devices, so as to facilitate developers to locate problems in a timely manner.

[0173] In some embodiments, the state rollback component can be executed by a separately created subprocess to save the state data recorded at the start state point and the end state point. The state data recorded at the state point may include data such as object field values, resource status, user interface status, etc.

[0174] The state rollback component is used to execute the state rollback processing logic when the global exception management component identifies an exception of the state recoverable category, and restore the target application to the state corresponding to the last stable end state point. For example, the state rollback processing logic may include: reloading saved data, reestablishing network connection, restoring the user interface, etc.

[0175] like Figure 8As shown, if during the running of the target application, an exception message appears when executing the target method 3, at this time, the global exception management component responds to the captured exception message, analyzes the exception message, and identifies the corresponding exception resolution category. If the global exception management component identifies that the exception message corresponds to the state recoverable category, the state rollback component responds to the global exception management component identifying the exception message of the state recoverable category, triggers the state rollback processing logic, and restores to the state corresponding to the end state point before the target method 3 is called. If the global exception management component identifies that the exception message corresponds to the state cannot be recovered category, then the process 1 is closed based on the preset exit strategy.

[0176] It can be seen from the above embodiments that all exceptions in the process are handled in a centralized location through the global exception management component, rather than being scattered in various modules or functions, which can ensure the consistency and uniformity of the exception handling logic, and can capture all exceptions that are not captured by the application code, so as to ensure that exceptions occurring anywhere will not be missed. Moreover, through the standardized process of the global exception management component and the state rollback component cooperating with each other, including capturing exception information, analyzing exception information based on preset analysis strategies, exception reporting, notification, exception resolution, etc., it can ensure that all exceptions are handled according to standardized processes, improve the reliability and maintainability of the system, and ensure that the system can handle exceptions as soon as possible after encountering them.

[0177] In some embodiments of the present application, capturing global exception information of the target application during the running of the target application includes:

[0178] During the operation of a Web-based application, global exception information of the Web-based application is captured, wherein a starting position of a method in the Web-based application for calling a target SDK is pre-set with a corresponding starting state point, and the starting state point is used to record state data of the Web-based application before the target SDK method is called.

[0179] In this embodiment, the Web-based application program can be understood as the target application.

[0180] Below, taking the method in which the Web-based application is a payment application applet and the target method is a method for calling an SDK (Software Development Kit) function as an example, the exception handling method provided in the embodiment of the present application is exemplarily described. A payment application is an application for processing and managing transactions in a payment scenario. The payment application can run on a smartphone, tablet computer, computer or other smart device, and communicate with banks, payment gateways and other financial service providers via an Internet connection to complete payment operations. For example, the method for calling an SDK function may include a method for calling a positioning function of a third-party SDK.

[0181] It is understandable that due to the defects of the third-party SDK itself, in extreme cases where there is no network connection and no location permission, calling the SDK positioning function may cause the payment application applet to abnormally crash, greatly affecting the user experience.

[0182] In view of this, according to the exception handling method provided in the embodiment of the present application, it is possible to implement an exception management solution that supports adaptive state recovery, effectively handle exceptions in payment application applets, avoid the bad experience caused by sudden crashes, and improve exception handling efficiency.

[0183] First, during the compilation phase of the payment application applet, the AOP technology is used to insert a start state point and an end state point before and after calling the positioning SDK method, so as to record the state data before and after calling the positioning SDK method.

[0184] When the payment application applet creates a process, a global exception management component is deployed in the process to capture and analyze exception information that occurs in the process.

[0185] For example: When an error occurs when calling the positioning SDK without a network and without positioning permissions, the global exception management component will capture the corresponding exception information, analyze the exception information based on the preset analysis strategy, and identify the corresponding exception resolution category. For the exception information when an error occurs when calling the positioning SDK, since the exception can be avoided by reopening the network or authorizing positioning permissions, the exception information will be identified as a recoverable category for the corresponding state. In this case, the global exception management component will trigger the exception notification inserted by the state rollback component during the compilation phase, and roll back the page of the payment application applet to the state before calling the positioning plug-in based on the most recent end state point. In this way, the user still sees the normal operating interface, and the exception only affects the display of the positioning results without affecting the normal use of other functions, which can significantly improve the stability of the application and user experience.

[0186] Another example: When the global exception management component in the process captures an OOM (Out of Memory Exception) exception, this indicates that the application's memory usage has reached the system limit and continuing to run may cause more serious problems. Based on the preset analysis strategy, the exception information is analyzed and identified as an exception that cannot be restored. Based on the preset exit strategy, the current process is actively closed and the currently occupied resources are cleaned up. Before closing the process, the global exception management component can output a prompt message to the user, which is used to explain that the payment application applet is closed due to resource constraints, and recommends that the user close some unnecessary applications or restart the device.

[0187] It can be seen from the above embodiments that, through the cooperation of the global exception management component and the state rollback component, comprehensive monitoring and classification processing of abnormal flashbacks are achieved during the operation stage of the payment application applet. For serious exceptions that belong to the category of unrecoverable status, the default exit strategy will be executed to actively and orderly close the relevant processes to ensure that users can experience a smooth exit process; for other exceptions that are identified as state-recoverable exceptions, state rollback is attempted first, aiming to restore the payment application applet to a stable operating state, while achieving the purpose of temporarily isolating the path that caused the exception, thereby avoiding potential continuous errors.

[0188] It should be noted that the acquisition, storage, use, and processing of information and data in this application have been authorized by users or relevant institutions and comply with relevant provisions of national laws and regulations.

[0189] A second aspect of the present application provides an exception handling device. Fig. 9 This is a schematic diagram of the structure of an exception handling device provided in an embodiment of the second aspect of the present application. Fig. 9 As shown, the exception handling device 900 may include an exception capturing module 910 , an exception analyzing module 920 , a state determining module 930 and a state recovering module 940 .

[0190] The exception capture module 910 may be used to capture global exception information of the target application during the operation of the target application.

[0191] The starting position of the target method of the target application is pre-set with a corresponding starting state point, and the starting state point is used to record the state data of the target application before the corresponding target method is executed.

[0192] The exception analysis module 920 may be used to analyze the exception information based on a preset analysis strategy and identify the exception resolution category corresponding to the exception information.

[0193] The state determination module 930 can be used to determine the target end state point from the end state point before the execution of the target method corresponding to the exception information when the exception resolution category is a state recoverable category, and use the start state point of the starting position of the target method corresponding to the exception information as the target start state point.

[0194] The state recovery module 940 may be used to recover the running state of the target application by using the state data of the target starting state point.

[0195] In some embodiments of the present application, the end position of the target method is pre-set with a corresponding end state point, and the end state point is used to record the state data of the target application after the corresponding target method is executed. The state determination module can be used to determine the target end state point from the end state point before the target method corresponding to the exception information is executed. The state recovery module can be used to use the state data recorded by the target starting state point and the target end state point to restore the running state of the target application to the state corresponding to the target end state point.

[0196] In some embodiments of the present application, the state data includes at least one of the following: state data of interface elements, state data of database transactions, snapshots of file system operations, and state data of network request responses. The device also includes: a first sub-process module, which is used to obtain and save the state data recorded at the start state point and / or the end state point through a first sub-process, wherein the first sub-process is a sub-process created separately from the process created for the target application.

[0197] In some embodiments of the present application, the device further includes:

[0198] The active exit module 950 may be used to close the process related to the exception information based on a preset exit strategy when the exception resolution category is a category where the status cannot be recovered.

[0199] In some embodiments of the present application, the exception capture module 910 can capture the global exception information of the target application through a global exception management component set in the process in which the target application runs.

[0200] The exception analysis module 920 may be used to analyze the exception information through a preset analysis strategy of the global exception management component, and identify the exception resolution category corresponding to the exception information.

[0201] The state recovery module 940 can be used to restore the running state of the target application to the state corresponding to the target end state point based on the state rollback component set in the process and using the state data recorded at the target start state point and the target end state point.

[0202] In some embodiments of the present application, the device further includes:

[0203] The state point insertion module can be used to traverse the methods in the target application during the compilation phase of the target application, insert a corresponding starting state point at the starting position of the code of the traversed method, and insert a corresponding ending state point at the ending position of the traversed method, wherein the target method is the traversed method.

[0204] In some embodiments of the present application, the exception analysis module 920 can be used to perform at least one of exception type analysis, exception context analysis, and exception impact analysis on the exception information based on a preset analysis strategy, to determine whether the exception resolution category corresponding to the exception information is a state that cannot be recovered category, and if the exception information does not correspond to a state that cannot be recovered category, determine that the exception resolution category corresponding to the exception information is a state that can be recovered category.

[0205] In some embodiments of the present application, the abnormality analysis module 920 may include:

[0206] The type analysis unit can be used to perform an abnormality type analysis on the abnormal information based on a preset analysis strategy, and when the abnormal information is analyzed to include a system-level abnormality, determine that the state corresponding to the abnormal information cannot be restored.

[0207] The context analysis unit can be used to perform exception context analysis on the exception information based on a preset analysis strategy, and determine that the state corresponding to the exception information cannot be restored when the context information related to the exception information includes key information marked by code annotations.

[0208] The impact analysis unit can be used to perform an abnormal impact analysis on the abnormal information based on a preset analysis strategy, and when it is analyzed that the operations related to the abnormal information include key operations or key components marked by code annotations, determine that the state corresponding to the abnormal information cannot be restored.

[0209] In some embodiments of the present application, the state recovery module 940 may include:

[0210] The database connection unit may be used to reconnect to the database based on the status data of the database transaction recorded at the target start status point and the target end status point.

[0211] The data loading unit may be used to reload application data based on the file system operation snapshot recorded at the target start state point and the target end state point.

[0212] The interface setting unit may be used to reset the interface elements based on the state data of the interface elements recorded at the target starting state point and the target ending state point.

[0213] In some embodiments of the present application, the device further includes:

[0214] The state recovery monitoring module can be used to monitor whether the running state of the target application is successfully restored to the state corresponding to the target end state point.

[0215] The recovery failure processing module can be used to close the process related to the abnormal information based on a preset exit strategy when the state corresponding to the target end state point is not successfully restored.

[0216] In some embodiments of the present application, the device further includes:

[0217] The state point insertion module can be used to traverse the methods in the target application during the compilation phase of the target application, insert a corresponding starting state point at the starting position of the code of the traversed method, and insert a corresponding ending state point at the ending position of the traversed method, wherein the target method is the traversed method.

[0218] In some embodiments of the present application, an exception capture module is used to capture global exception information of a Web-based application during its operation, wherein a starting position of a method in the Web-based application for calling a target SDK is pre-set with a corresponding starting state point, and the starting state point is used to record state data of the Web-based application before the target SDK method is called.

[0219] It should be noted that the exception handling device 900 is a device corresponding to the above-mentioned exception handling method. All implementation methods in the above-mentioned method embodiment are applicable to the embodiment of the device and can achieve the same technical effect.

[0220] The third aspect of the present application also provides an exception handling device. Fig.10 This is a schematic diagram of the structure of an exception handling device provided in one embodiment of the present application. Fig.10 As shown, the exception handling device 1000 includes a memory 1001 , a processor 1002 , and a computer program stored in the memory 1001 and executable on the processor 1002 .

[0221] In some examples, the processor 1002 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0222] The memory 1001 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 1001 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these.

[0223] The memory 1001 may include a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the exception handling method in the embodiment of the present application.

[0224] The processor 1002 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 1001, so as to implement the exception handling method in the above embodiment.

[0225] In some examples, the exception handling device 1000 may further include a communication interface 1003 and a bus 1004. Fig.10 As shown, the memory 1001, the processor 1002, and the communication interface 1003 are connected via a bus 1004 and communicate with each other.

[0226] The communication interface 1003 is mainly used to realize the communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 1003 can also be used to access input devices and / or output devices.

[0227] The bus 1004 includes hardware, software or both, coupling the components of the exception handling device 1000 to each other. For example, but not limitation, the bus 1004 may include an accelerated graphics port (Accelerated Graphics Port, AGP) or other graphics bus, an enhanced industry standard architecture (Enhanced Industry Standard Architecture, EISA) bus, a front side bus (Front Side Bus, FSB), a hypertransport (Hyper Transport, HT) interconnection, an industry standard architecture (Industry Standard Architecture, ISA) bus, an infinite bandwidth interconnection, a low pin count (Low pin count, LPC) bus, a memory bus, a micro channel architecture (Micro Channel Architecture, MCA) bus, a peripheral component interconnect (Peripheral Component Interconnect, PCI) bus, a PCI-Express (PCI-E) bus, a serial advanced technology attachment (Serial Advanced Technology Attachment, SATA) bus, a video electronics standards association local (Video Electronics Standards Association Local Bus, VLB) bus or other suitable buses or a combination of two or more of these. Where appropriate, the bus 1004 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.

[0228] In a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program instruction is stored, and when the computer program instruction is executed by a processor, the exception handling method in the above embodiment can be implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the above-mentioned computer-readable storage medium may include a non-transitory computer-readable storage medium, such as a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), a disk or an optical disk, etc., which is not limited here.

[0229] The present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the exception handling method in the above embodiment is implemented and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0230] It should be clear that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For device embodiments, equipment embodiments, and computer-readable storage medium embodiments, the relevant parts can refer to the description part of the method embodiment. The present application is not limited to the specific steps and structures described above and shown in the figures. Those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application. In addition, for the sake of brevity, a detailed description of known method technologies is omitted here.

[0231] The above reference is according to the method of the embodiment of the present application, the flow chart of the device (system) and the computer program product and / or the block diagram described various aspects of the present application.It should be understood that each square box in the flow chart and / or the block diagram and the combination of each square box in the flow chart and / or the block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the realization of the function / action specified in one or more square boxes of the flow chart and / or the block diagram.Such a processor can be but is not limited to a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.It can also be understood that each square box in the block diagram and / or the flow chart and the combination of the square boxes in the block diagram and / or the flow chart can also be realized by the dedicated hardware that performs the specified function or action, or can be realized by the combination of dedicated hardware and computer instructions.

[0232] Those skilled in the art should understand that the above embodiments are exemplary rather than restrictive. Different technical features appearing in different embodiments can be combined to achieve beneficial effects. Based on the study of the drawings, the specification and the claims, those skilled in the art should be able to understand and implement other variations of the disclosed embodiments. In the claims, the term "comprising" does not exclude other devices or steps; the quantifier "one" does not exclude multiple; the terms "first" and "second" are used to indicate names rather than to indicate any specific order. Any figure marks in the claims should not be understood as limiting the scope of protection. The functions of multiple parts appearing in the claims can be implemented by a single hardware or software module. The appearance of certain technical features in different dependent claims does not mean that these technical features cannot be combined to achieve beneficial effects.

Claims

1. An exception handling method, characterized in that: include: During the operation of the target application, capturing global exception information of the target application, wherein the starting position of the target method of the target application is pre-set with a corresponding starting state point, and the starting state point is used to record the state data of the target application before the corresponding target method is executed; Based on a preset analysis strategy, the abnormal information is analyzed to identify the abnormality resolution category corresponding to the abnormal information; In the case where the exception resolution category is a state recoverable category, taking the starting state point of the target method starting position corresponding to the exception information as the target starting state point; The running state of the target application is restored using the state data recorded at the target starting state point.

2. The method according to claim 1, characterized in that: The end position of the target method is pre-set with a corresponding end state point, and the end state point is used to record the state data of the target application after the corresponding target method is executed; The restoring the running state of the target application by using the state data recorded at the target starting state point includes: Determine a target end state point from the end state point before the target method corresponding to the exception information is executed; The running state of the target application is restored to the state corresponding to the target end state point by using the state data recorded by the target start state point and the target end state point.

3. The method according to claim 2, characterized in that The state data includes: at least one of the state data of interface elements, state data of database transactions, file system operation snapshots, and state data of network request responses; The method further comprises: The state data recorded at the start state point and / or the end state point is acquired and saved through a first sub-process, where the first sub-process is a sub-process created separately from a process created for the target application.

4. The method according to claim 3, characterized in that: The using the state data recorded by the target starting state point and the target ending state point to restore the running state of the target application to the state corresponding to the target ending state point includes: Reconnecting to the database based on the state data of the database transaction recorded at the target start state point and the target end state point; Reloading application data based on the file system operation snapshots recorded at the target starting state point and the target ending state point; Reestablishing a network connection based on the state data of the network request response recorded at the target starting state point and the target ending state point; The interface elements are reset based on the state data of the interface elements recorded at the target starting state point and the target ending state point.

5. The method according to claim 1, characterized in that The method further comprises: When the exception resolution category is a category where the status cannot be restored, the process related to the exception information is closed based on a preset exit strategy.

6. The method according to claim 5, characterized in that The preset exit strategy includes: Output exit prompt information; Saving the abnormal information; The process of the target method corresponding to the exception information is closed, and the main process of the target application is started.

7. The method according to claim 1, characterized in that The capturing of global abnormal information of the target application during the running of the target application includes: Capturing global exception information of the target application by setting a global exception management component in the process in which the target application is running; The analyzing the abnormal information based on the preset analysis strategy to identify the abnormality resolution category corresponding to the abnormal information includes: Analyze the exception information through the preset analysis strategy of the global exception management component to identify the exception resolution category corresponding to the exception information; The restoring the running state of the target application by using the state data recorded at the target starting state point includes: Based on the state rollback component set in the process, the running state of the target application is restored using the state data recorded at the target starting state point.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: During the target application compilation phase, the methods in the target application are traversed, a corresponding starting state point is inserted at the beginning of the code of the traversed method, and a corresponding ending state point is inserted at the end of the traversed method, and the target method is the traversed method.

9. The method according to any one of claims 1 to 7, characterized in that: The analyzing the abnormal information based on the preset analysis strategy to identify the abnormality resolution category corresponding to the abnormal information includes: Based on a preset analysis strategy, at least one of an abnormality type analysis, an abnormality context analysis, and an abnormality impact analysis is performed on the abnormal information to determine whether the abnormality resolution category corresponding to the abnormal information is a status unrecoverable category; In the case that the abnormal information does not correspond to the status cannot be recovered category, it is determined that the abnormality resolution category corresponding to the abnormal information is the status can be recovered category.

10. The method according to claim 9, characterized in that The performing at least one of an abnormality type analysis, an abnormality context analysis, and an abnormality impact analysis on the abnormal information based on a preset analysis strategy to determine whether the abnormality resolution category corresponding to the abnormal information is a category where the status cannot be recovered includes: Performing an abnormality type analysis on the abnormal information based on a preset analysis strategy, and in the case where the abnormal information is analyzed to include a system-level abnormality, determining that the state corresponding to the abnormal information cannot be restored; Performing an exception context analysis on the exception information based on a preset analysis strategy, and analyzing that context information related to the exception information includes key information marked by a code annotation, determining that the state corresponding to the exception information cannot be restored; When the abnormal impact analysis is performed on the abnormal information based on a preset analysis strategy and it is found that the operation related to the abnormal information includes a key operation or a key component marked by a code annotation, it is determined that the state corresponding to the abnormal information is a category that cannot be recovered.

11. The method according to claim 5, characterized in that The method further comprises: Monitoring whether the running state of the target application is successfully restored; In the event of unsuccessful recovery, the process related to the abnormal information is closed based on a preset exit strategy.

12. The method according to any one of claims 1 to 7, characterized in that: The capturing of global abnormal information of the target application during the running of the target application includes: During the operation of a Web-based application, global exception information of the Web-based application is captured, wherein a starting position of a method in the Web-based application for calling a target SDK is pre-set with a corresponding starting state point, and the starting state point is used to record state data of the Web-based application before the target SDK method is called.

13. An exception handling device, characterized in that: The device comprises: An exception capture module is used to capture global exception information of the target application during its operation, wherein the starting position of the target method of the target application is pre-set with a corresponding starting state point, and the starting state point is used to record the state data of the target application before the corresponding target method is executed; An exception analysis module, used to analyze the exception information based on a preset analysis strategy and identify the exception resolution category corresponding to the exception information; A state determination module, configured to, when the exception resolution category is a state recoverable category, use the starting state point of the target method starting position corresponding to the exception information as the target starting state point; The state recovery module is used to recover the running state of the target application by using the state data of the target starting state point.

14. An exception handling device, characterized in that: include: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the exception handling method according to any one of claims 1 to 12 is implemented.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the exception handling method according to any one of claims 1 to 12 is implemented.

16. A computer program product, characterized in that The invention comprises a computer program, wherein when the computer program is executed by a processor, the exception handling method according to any one of claims 1 to 12 is implemented.