CN114996098B - Exception handling method and device - Google Patents

Exception handling method and device Download PDF

Info

Publication number
CN114996098B
CN114996098B CN202210731193.2A CN202210731193A CN114996098B CN 114996098 B CN114996098 B CN 114996098B CN 202210731193 A CN202210731193 A CN 202210731193A CN 114996098 B CN114996098 B CN 114996098B
Authority
CN
China
Prior art keywords
abnormal
receiver
exception
information
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210731193.2A
Other languages
Chinese (zh)
Other versions
CN114996098A (en
Inventor
韩玉飞
苏景博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongdian Jinxin Software Co Ltd
Original Assignee
Zhongdian Jinxin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongdian Jinxin Software Co Ltd filed Critical Zhongdian Jinxin Software Co Ltd
Priority to CN202210731193.2A priority Critical patent/CN114996098B/en
Publication of CN114996098A publication Critical patent/CN114996098A/en
Application granted granted Critical
Publication of CN114996098B publication Critical patent/CN114996098B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • H04L12/1813Arrangements for providing special services to substations for broadcast or conference, e.g. multicast for computer conferences, e.g. chat rooms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/04Real-time or near real-time messaging, e.g. instant messaging [IM]
    • H04L51/046Interoperability with other network applications or services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2212/00Encapsulation of packets

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Signal Processing (AREA)
  • Mathematical Physics (AREA)
  • Multimedia (AREA)
  • Computer And Data Communications (AREA)
  • Alarm Systems (AREA)

Abstract

The application provides an exception handling method and device, comprising the following steps: intercepting an abnormal broadcast thrown out by a controller in an application program through a global abnormal processing class preset in the application program, wherein the abnormal broadcast indicates that the business process processed by the controller is abnormal; determining a target exception type to which the exception broadcast belongs; calling an extraction function corresponding to the target exception type from a global exception handling class, wherein the global exception handling class comprises a plurality of extraction functions, and each extraction function corresponds to one exception type; extracting abnormal information from the abnormal broadcasting by extracting a function; searching abnormal receiver information from the global abnormal processing class; and encapsulating the abnormal information according to the information of the abnormal receiver, and transmitting the encapsulated abnormal information to the abnormal receiver. According to the method and the device, the abnormality in the application program is timely sent to the abnormality receiving party, so that the user can timely receive the abnormality prompt.

Description

Exception handling method and device
Technical Field
The present disclosure relates to the field of program exception handling, and in particular, to an exception handling method and apparatus.
Background
Anomaly monitoring is a skill that many operation and maintenance workers or development workers must possess. At present, when an application program runs in a server, the server records abnormal information of the application program in a log mode. When an operation and maintenance worker or a development worker monitors the abnormality of the application program, the abnormality information needs to be actively searched from a large number of logs, so that the abnormality information of the application program cannot be monitored in time.
Disclosure of Invention
In view of this, an object of the present application is to provide at least one method and apparatus for exception handling, which enable a user to receive an exception prompt in time by timely sending an exception in an application program to an exception receiving party.
The application mainly comprises the following aspects:
in a first aspect, an embodiment of the present application provides an exception handling method, including: intercepting an abnormal broadcast thrown out by a controller in an application program through a global abnormal processing class preset in the application program, wherein the abnormal broadcast indicates that the business process processed by the controller is abnormal; determining a target exception type to which the exception broadcast belongs; calling an extraction function corresponding to the target exception type from a global exception handling class, wherein the global exception handling class comprises a plurality of extraction functions, and each extraction function corresponds to one exception type; extracting abnormal information from the abnormal broadcasting by extracting a function; searching abnormal receiver information from the global abnormal processing class; and encapsulating the abnormal information according to the information of the abnormal receiver, and transmitting the encapsulated abnormal information to the abnormal receiver.
In one possible implementation, the step of encapsulating the anomaly information according to the information of the anomaly receiver includes: extracting a communication protocol established between the application program and the abnormal receiver from information of the abnormal receiver; determining a message type of communication between the application program indicated by the communication protocol and the abnormal receiver; determining a preset target protocol format under the message type; and encapsulating the abnormal information according to the target protocol format.
In one possible implementation, the step of sending the encapsulated anomaly information to the anomaly receiver includes: extracting a communication interface of an abnormal receiver from the abnormal receiver information; calling a communication interface of an abnormal receiver, and determining a message receiving address of the abnormal receiver corresponding to the communication interface; and sending the packaged abnormal information to a message receiving address of an abnormal receiver through a communication interface.
In one possible implementation, the abnormal receiver is an instant messaging application, and the message receiving address indicates a chat group pre-created in the instant messaging application, and members of the chat group include abnormal maintainers of the application.
In one possible implementation, the communication interface of the abnormal receiver is created by: defining an initial communication interface, wherein the initial communication interface comprises an interface name and an interface body, the interface name indicates an instant messaging application program, and the interface body is empty; creating a message sending strategy aiming at an abnormal receiver, wherein the message sending strategy is used for sending the packaged abnormal information to an instant messaging application program; adding a message sending policy to an interface body of the initial communication interface; and setting a message receiving address corresponding to the message sending strategy to finish the creation of the communication interface of the abnormal receiver.
In one possible implementation manner, the global exception handling class is enhanced by the controller to annotate marks, the global exception handling class includes a plurality of interception processing rules marked by exception interception notes, each interception processing rule is used for intercepting exception broadcasting of an exception type indicated under the interception processing rule, each interception processing rule includes a rule name and Fang Fati, and an extraction function of the exception type corresponding to the interception processing rule is set in a method body of the interception processing rule.
In a second aspect, an embodiment of the present application further provides an exception handling apparatus, where the exception handling apparatus includes: the interception module is used for intercepting abnormal broadcasting thrown by a controller in the application program through a global abnormal processing class preset in the application program, wherein the abnormal broadcasting indicates that the business process processed by the controller is abnormal; the determining module is used for determining the target exception type to which the exception broadcast belongs; the calling module is used for calling the extraction function corresponding to the target exception type from the global exception handling class, wherein the global exception handling class comprises a plurality of extraction functions, and each extraction function corresponds to one exception type; the extraction module is used for extracting the abnormal information from the abnormal broadcast through the extraction function; the searching module is used for searching the abnormal receiver information from the global abnormal processing class; and the packaging module is used for packaging the abnormal information according to the information of the abnormal receiver and sending the packaged abnormal information to the abnormal receiver.
In one possible embodiment, the packaging module is further configured to: extracting a communication protocol established between the application program and the abnormal receiver from information of the abnormal receiver; determining a message type of communication between the application program indicated by the communication protocol and the abnormal receiver; determining a preset target protocol format under the message type; and encapsulating the abnormal information according to the target protocol format.
In one possible embodiment, the packaging module is further configured to: extracting a communication interface of an abnormal receiver from the abnormal receiver information; calling a communication interface of an abnormal receiver, and determining a message receiving address of the abnormal receiver corresponding to the communication interface; and sending the packaged abnormal information to a message receiving address of an abnormal receiver through a communication interface.
In a third aspect, embodiments of the present application further provide an electronic device, including: a processor, a memory and a bus, the memory storing machine readable instructions executable by the processor, the processor and the memory in communication via the bus when the electronic device is running, the machine readable instructions when executed by the processor performing the steps of the exception handling method of any one of the possible implementations of the first aspect or the first aspect.
The method and the device for processing the exception provided by the embodiment of the application comprise the following steps: intercepting an abnormal broadcast thrown out by a controller in an application program through a global abnormal processing class preset in the application program, wherein the abnormal broadcast indicates that the business process processed by the controller is abnormal; determining a target exception type to which the exception broadcast belongs; calling an extraction function corresponding to the target exception type from a global exception handling class, wherein the global exception handling class comprises a plurality of extraction functions, and each extraction function corresponds to one exception type; extracting abnormal information from the abnormal broadcasting by extracting a function; searching abnormal receiver information from the global abnormal processing class; and encapsulating the abnormal information according to the information of the abnormal receiver, and transmitting the encapsulated abnormal information to the abnormal receiver. According to the method and the device, the abnormality in the application program is timely sent to the abnormality receiving party, so that the user can timely receive the abnormality prompt.
In order to make the above objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered limiting the scope, and that other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating steps of an exception handling method provided by an embodiment of the present application;
fig. 2 is a schematic functional block diagram of an exception handling apparatus according to an embodiment of the present application;
fig. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the accompanying drawings in the present application are only for the purpose of illustration and description, and are not intended to limit the protection scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this application, illustrates operations implemented according to some embodiments of the present application. It should be appreciated that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to the flow diagrams and one or more operations may be removed from the flow diagrams as directed by those skilled in the art.
In addition, the described embodiments are only some, but not all, of the embodiments of the present application. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be within the scope of the present application.
The abnormality monitoring is a skill which many operation and maintenance staff or development staff must master, but since the server does not have the function of abnormality reminding, only abnormality display can be achieved, and thus abnormal information and conditions cannot be monitored in time.
Based on this, the embodiment of the application provides an exception handling method, which enables a user to timely receive an exception prompt by timely sending an exception in an application program to an exception receiver, and specifically comprises the following steps:
referring to fig. 1, fig. 1 is a flowchart illustrating steps of an exception handling method according to an embodiment of the present application. As shown in fig. 1, the exception handling method provided in the embodiment of the present application includes the following steps:
s100, intercepting abnormal broadcasting thrown by a controller in an application program through a global abnormal processing class preset in the application program.
Specifically, the exception broadcasting indicates that the business processes processed by the controller are abnormal, the controller layer of the application program comprises a plurality of controllers for processing different business processes, each controller can actively throw out generated exception broadcasting when the processed business processes are abnormal, in the prior art, the exception is generally captured through a standard try-catch function, but the try-catch function is suitable for maintenance personnel to actively capture and process the exception which occurs in the application program, but if the application program is abnormal during operation, the maintenance personnel cannot timely process the occurrence of the exception, and the method provided by the application can actively intercept the exception broadcasting thrown out by each controller.
S200, determining the target exception type to which the exception broadcast belongs.
In one embodiment, the exception indicated by the exception broadcast includes a plurality of exception types, the exception handling rules include sub-handling rules corresponding to each exception type, the exception types include, but are not limited to, null pointers, under-memory errors, stack overflow errors, and out-of-index exceptions, and the exception broadcast casts out while indicating the exception type it casts out.
S300, calling an extraction function corresponding to the target exception type from the global exception handling class.
The global exception handling class comprises a plurality of extraction functions, and each extraction function corresponds to one exception type.
In a specific embodiment, the global exception handling class is enhanced by the controller to annotate marks, the global exception handling class includes a plurality of interception processing rules marked by exception interception notes, each interception processing rule is used for intercepting exception broadcasting of an exception type indicated under the interception processing rule, each interception processing rule includes a rule name and Fang Fati, and an extraction function of the exception type corresponding to the interception processing rule is set in a method body of the interception processing rule.
In a specific embodiment, each interception processing rule is placed in the global exception handling class after being marked by an exception interception annotation, so as to intercept exception broadcasting by the global exception handling class, and specifically, the exception interception annotation is used for declaring the exception type intercepted by the interception processing rule.
Specifically, an interception processing rule with a rule name of interception processing rule can be called, then a strategy for performing exception handling on the exception is added in a method body corresponding to the interception processing rule, the strategy for performing exception handling on the exception includes but is not limited to an extraction function, an exception information encapsulation function and the like, then the interception processing rule can be marked by using @ interception processing rule, and an exception type intercepted by the interception processing rule can be declared by adding a corresponding value to @ interception processing rule, wherein the exception of the appointed exception type thrown by a controller can be intercepted by adding the appointed exception type to the value of @ interception processing rule, and then the exception of the appointed exception type can be handled by using the interception processing rule under @ interception processing rule.
In another preferred embodiment, the method for intercepting exception broadcast by the global exception handling class comprises the following steps: adding all marked interception processing rules to a global exception handling class; and performing controller enhanced annotation marking on the global exception handling class so that the marked global exception handling class can intercept and process exception broadcasting thrown by all controllers in the application program.
Illustratively, a global exception handling class with a class name of globalException handler may be created, and then the global exception handling class with a class name of globalException handler is marked by @ controller rad device, where @ controller rad device is a controller enhancement annotation, where @ controller rad device may uniformly process exceptions thrown by all controllers in an application program, and then all interception processing rules marked by @ Exception handler are added to the global exception handling class with a class name of globalException handler, so that exception broadcasting thrown by all controllers in the application program may be intercepted and processed by the global exception handling class with a class name of globalException handler.
S400, extracting the abnormal information from the abnormal broadcasting through the extraction function.
Illustratively, if an interception processing rule in the global exception handling class intercepts an exception broadcast thrown by the controller, then the extraction function in the interception processing rule extracts exception information from the exception broadcast.
In one embodiment, the exception information encapsulation function may be a getMessage function provided by java.
S500, searching abnormal receiver information from the global abnormal processing class.
The abnormal receiver is a communication object which is defined in the global abnormal processing class and used for receiving abnormal information, and the abnormal receiver information comprises, but is not limited to, a communication protocol established between an application program and the abnormal receiver, a message type for communication between the application program indicated by the communication protocol and the abnormal receiver, a target protocol format preset under the message type, a communication interface of the abnormal receiver and a message receiving address of the abnormal receiver.
S600, packaging the abnormal information according to the information of the abnormal receiver, and sending the packaged abnormal information to the abnormal receiver.
In a preferred embodiment, the step of encapsulating the anomaly information according to the information of the anomaly receiver includes:
and extracting a communication protocol established between the application program and the abnormal receiver from the information of the abnormal receiver, determining the message type of the communication between the application program indicated by the communication protocol and the abnormal receiver, determining a preset target protocol format under the message type, and packaging the abnormal information according to the target protocol format.
In a specific embodiment, the abnormal receiver is an instant messaging application program, wherein the message type comprises a text message type, and the protocol format corresponding to the message type comprises, but is not limited to, an XML format and a JSON format.
In a preferred embodiment, the step of transmitting the encapsulated anomaly information to the anomaly receiver includes:
extracting the communication interface of the abnormal receiver from the information of the abnormal receiver, calling the communication interface of the abnormal receiver, determining the message receiving address of the abnormal receiver corresponding to the communication interface, and sending the packaged abnormal information to the message receiving address of the abnormal receiver through the communication interface.
The message receiving address indicates a chat group which is pre-established in the instant messaging application program, members of the chat group comprise abnormal maintainers of the application program, and the instant messaging program comprises, but is not limited to enterprise WeChat and nail, wherein the message address of the abnormal receiver is an address corresponding to the chat group which is pre-established in the instant messaging application program.
In a specific implementation, the communication interface of the abnormal receiver is created by: defining an initial communication interface, wherein the initial communication interface comprises an interface name and an interface body, the interface name indicates an instant messaging application program, the interface body is empty, a message sending strategy aiming at an abnormal receiver is created, the message sending strategy is used for sending the packaged abnormal information to the instant messaging application program, the message sending strategy is added to the interface body of the initial communication interface, and a message receiving address corresponding to the message sending strategy is set so as to complete the creation of the communication interface of the abnormal receiver.
The message sending policy is used for sending the encapsulated abnormal information to the instant messaging application program, and an initial communication interface with an interface name of qyWechat can be defined through spring-closed-starter-opening provided by spring-closed-opening, the interface is used for communicating with enterprise Wechat, then a message sending policy for an abnormal receiver is created, the message sending policy is added to an interface body of the initial communication interface, then the communication interface to which the message sending policy is added is marked through @ PostMapping, and a message receiving address corresponding to the message sending policy is declared through @ PostMapping, namely, a webhook address of a chat group for receiving the abnormal information is declared through @ PostMapping, wherein in the enterprise Webook, a webhook address of the chat group for receiving the abnormal information can be obtained through a group robot function provided by the enterprise Webook.
Based on the same application conception, the embodiment of the present application further provides an exception handling device for an application corresponding to the exception handling method provided in the foregoing embodiment, and since the principle of solving the problem by the device in the embodiment of the present application is similar to that of the exception handling method in the foregoing embodiment of the present application, implementation of the device may refer to implementation of the method, and repeated parts will not be repeated.
Referring to fig. 2, fig. 2 is a schematic functional block diagram of an exception handling apparatus according to an embodiment of the present application, where, as shown in fig. 2, the exception handling apparatus includes:
the interception module 510 is configured to intercept, by using a global exception handling class preset in an application program, an exception broadcast thrown by a controller in the application program, where the exception broadcast indicates that an exception exists in a business process handled by the controller;
a determining module 520, configured to determine a target exception type to which the exception broadcast belongs;
a calling module 530, configured to call an extraction function corresponding to the target exception type from the global exception handling class, where the global exception handling class includes a plurality of extraction functions, and each extraction function corresponds to an exception type;
an extracting module 540 for extracting the abnormal information from the abnormal broadcasting by extracting the function;
a searching module 550, configured to search the global exception handling class for exception receiver information;
and the encapsulation module 560 is configured to encapsulate the anomaly information according to the information of the anomaly receiver, and send the encapsulated anomaly information to the anomaly receiver.
Preferably, the packaging module 560 is further configured to:
extracting a communication protocol established between the application program and the abnormal receiver from information of the abnormal receiver; determining a message type of communication between the application program indicated by the communication protocol and the abnormal receiver; determining a preset target protocol format under the message type; and encapsulating the abnormal information according to the target protocol format.
Preferably, the packaging module 560 is further configured to:
extracting a communication interface of an abnormal receiver from the abnormal receiver information; calling a communication interface of an abnormal receiver, and determining a message receiving address of the abnormal receiver corresponding to the communication interface; and sending the packaged abnormal information to a message receiving address of an abnormal receiver through a communication interface.
Preferably, the abnormal receiver is an instant messaging application program, and the message receiving address indicates a chat group pre-created in the instant messaging application program, and members of the chat group comprise abnormal maintenance personnel of the application program.
Preferably, the packaging module 560 is further configured to:
defining an initial communication interface, wherein the initial communication interface comprises an interface name and an interface body, the interface name indicates an instant messaging application program, and the interface body is empty; creating a message sending strategy aiming at an abnormal receiver, wherein the message sending strategy is used for sending the packaged abnormal information to an instant messaging application program; adding a message sending policy to an interface body of the initial communication interface; and setting a message receiving address corresponding to the message sending strategy to finish the creation of the communication interface of the abnormal receiver.
Preferably, the global exception handling class is enhanced by the controller to annotate the annotation, the global exception handling class includes a plurality of interception processing rules marked by exception interception annotation, each interception processing rule is used for intercepting exception broadcasting of an exception type indicated under the interception processing rule, each interception processing rule includes a rule name and Fang Fati, and an extraction function of the exception type corresponding to the interception processing rule is set in a method body of the interception processing rule.
Referring to fig. 3 based on the same application concept, fig. 3 shows a schematic structural diagram of an electronic device 600 according to an embodiment of the present application, including: a processor 610, a memory 620 and a bus 630, said memory 620 storing machine readable instructions executable by said processor 610, said processor 610 and said memory 620 communicating via said bus 630 when said electronic device 600 is running, said machine readable instructions being executed by said processor 610 to perform the steps of the exception handling method according to any of the above embodiments.
Based on the same application concept, the embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of the exception handling method provided in the above embodiment are executed.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solutions of the present application may be embodied in essence or a part contributing to the prior art or a part of the technical solutions, or in the form of a software product, which is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes or substitutions are covered in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (7)

1. An exception handling method, comprising:
intercepting an abnormal broadcast thrown by a controller in an application program through a global abnormal processing class preset in the application program, wherein the abnormal broadcast indicates that an abnormal exists in a business process processed by the controller;
determining a target exception type to which the exception broadcast belongs;
calling an extraction function corresponding to the target exception type from the global exception handling class, wherein the global exception handling class comprises a plurality of extraction functions, each extraction function corresponds to one exception type, the global exception handling class comprises a plurality of interception processing rules marked by exception interception notes, each interception processing rule is used for intercepting exception broadcasting of the exception type indicated under the interception processing rule, each interception processing rule comprises a rule name and Fang Fati, and the extraction function of the exception type corresponding to the interception processing rule is arranged in a method body of the interception processing rule;
extracting abnormal information from the abnormal broadcasting through the extraction function;
searching abnormal receiver information from the global abnormal processing class;
encapsulating the abnormal information according to the information of the abnormal receiver, and sending the encapsulated abnormal information to the abnormal receiver;
the abnormal receiver is a communication object which is defined in the global abnormal processing class and used for receiving abnormal information, the abnormal receiver information comprises a communication protocol established between an application program and the abnormal receiver, a message type indicated by the communication protocol and used for communication between the application program and the abnormal receiver, a preset target protocol format under the message type, a communication interface of the abnormal receiver and a message receiving address of the abnormal receiver, and the message receiving address indicates a chat group which is created in advance in the instant messaging application program;
the step of sending the encapsulated anomaly information to an anomaly receiver comprises the following steps:
extracting communication interface of the abnormal receiver from the information of the abnormal receiver, calling the communication interface of the abnormal receiver, determining message receiving address of the abnormal receiver corresponding to the communication interface, transmitting the packaged abnormal information to the message receiving address of the abnormal receiver through the communication interface, wherein the communication interface comprises a message transmitting strategy which is used for transmitting the packaged abnormal information to an instant messaging application program,
defining an initial communication interface through @ FeignClient provided by spring-closed-starter-opening, wherein the initial communication interface comprises an interface name and an interface body, the interface name indicates the instant messaging application program, the interface body is empty, a message sending strategy aiming at an abnormal receiver is created, the message sending strategy is added to the interface body of the initial communication interface, then the communication interface added with the message sending strategy is marked through @ PostMapping, and the creation of the communication interface of the abnormal receiver is completed through @ PostMapping declaring a message receiving address corresponding to the message sending strategy.
2. The abnormality processing method according to claim 1, characterized in that the step of packaging the abnormality information according to the information of the abnormality receiving side includes:
extracting a communication protocol established between the application program and the abnormal receiver from the information of the abnormal receiver;
determining the message type of communication between the application program indicated by the communication protocol and the abnormal receiver;
determining a preset target protocol format under the message type;
and encapsulating the abnormal information according to the target protocol format.
3. The exception handling method of claim 1, wherein the exception recipient is an instant messaging application and the members of the chat group comprise exception maintainers of the application.
4. The exception handling method of claim 1, wherein the global exception handling class is enhanced by a controller by annotation tags.
5. An exception handling apparatus, characterized in that the exception handling apparatus comprises:
the interception module is used for intercepting abnormal broadcasting thrown by a controller in the application program through a global abnormal processing class preset in the application program, wherein the abnormal broadcasting indicates that the business process processed by the controller is abnormal;
the determining module is used for determining the target abnormality type to which the abnormality broadcast belongs;
the call module is used for calling the extraction function corresponding to the target exception type from the global exception handling class, wherein the global exception handling class comprises a plurality of extraction functions, each extraction function corresponds to one exception type, the global exception handling class comprises a plurality of interception processing rules marked by exception interception notes, each interception processing rule is used for intercepting exception broadcasting of the exception type indicated under the interception processing rule, each interception processing rule comprises a rule name and Fang Fati, and the extraction function of the exception type corresponding to the interception processing rule is arranged in a method body of the interception processing rule;
the extraction module is used for extracting abnormal information from the abnormal broadcast through the extraction function;
the searching module is used for searching abnormal receiver information from the global abnormal processing class;
the packaging module is used for packaging the abnormal information according to the information of the abnormal receiver and sending the packaged abnormal information to the abnormal receiver;
the abnormal receiver is a communication object which is defined in the global abnormal processing class and used for receiving abnormal information, the abnormal receiver information comprises a communication protocol established between an application program and the abnormal receiver, a message type indicated by the communication protocol and used for communication between the application program and the abnormal receiver, a preset target protocol format under the message type, a communication interface of the abnormal receiver and a message receiving address of the abnormal receiver, and the message receiving address indicates a chat group which is created in advance in the instant messaging application program;
the packaging module is also used for:
extracting communication interface of the abnormal receiver from the information of the abnormal receiver, calling the communication interface of the abnormal receiver, determining message receiving address of the abnormal receiver corresponding to the communication interface, transmitting the packaged abnormal information to the message receiving address of the abnormal receiver through the communication interface, wherein the communication interface comprises a message transmitting strategy which is used for transmitting the packaged abnormal information to an instant messaging application program,
defining an initial communication interface through @ FeignClient provided by spring-closed-starter-opening, wherein the initial communication interface comprises an interface name and an interface body, the interface name indicates the instant messaging application program, the interface body is empty, a message sending strategy aiming at an abnormal receiver is created, the message sending strategy is added to the interface body of the initial communication interface, then the communication interface added with the message sending strategy is marked through @ PostMapping, and the creation of the communication interface of the abnormal receiver is completed through @ PostMapping declaring a message receiving address corresponding to the message sending strategy.
6. The exception handling apparatus of claim 5, wherein the encapsulation module is further to:
extracting a communication protocol established between the application program and the abnormal receiver from the information of the abnormal receiver;
determining the message type of communication between the application program indicated by the communication protocol and the abnormal receiver;
determining a preset target protocol format under the message type;
and encapsulating the abnormal information according to the target protocol format.
7. An electronic device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating via said bus when the electronic device is running, said machine readable instructions when executed by said processor performing the steps of the exception handling method according to any of claims 1 to 4.
CN202210731193.2A 2022-06-24 2022-06-24 Exception handling method and device Active CN114996098B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210731193.2A CN114996098B (en) 2022-06-24 2022-06-24 Exception handling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210731193.2A CN114996098B (en) 2022-06-24 2022-06-24 Exception handling method and device

Publications (2)

Publication Number Publication Date
CN114996098A CN114996098A (en) 2022-09-02
CN114996098B true CN114996098B (en) 2024-04-09

Family

ID=83037848

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210731193.2A Active CN114996098B (en) 2022-06-24 2022-06-24 Exception handling method and device

Country Status (1)

Country Link
CN (1) CN114996098B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117806864A (en) * 2023-12-15 2024-04-02 东土科技(宜昌)有限公司 Nail pushing method and device based on abnormal message

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104503918A (en) * 2015-01-12 2015-04-08 北京国双科技有限公司 Handling method and device for abnormal information
CN106708706A (en) * 2015-11-12 2017-05-24 北京国双科技有限公司 Task program exception alarm information processing method and apparatus
CN108304447A (en) * 2017-12-07 2018-07-20 北京趣拿软件科技有限公司 Processing method, device, storage medium and the processor of exception information
CN108762966A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 System exception hold-up interception method, device, computer equipment and storage medium
CN109981621A (en) * 2019-03-15 2019-07-05 厦门美图之家科技有限公司 Network request processing method and processing device
CN110275791A (en) * 2018-03-14 2019-09-24 普天信息技术有限公司 A kind of application exception processing method and processing device
CN113160024A (en) * 2021-04-30 2021-07-23 中国银行股份有限公司 Business management system and method based on micro-service architecture
CN113778985A (en) * 2021-08-19 2021-12-10 上海东普信息科技有限公司 Microservice architecture monitoring method, microservice architecture monitoring device, computer equipment and storage medium
CN114371949A (en) * 2020-10-15 2022-04-19 腾讯科技(深圳)有限公司 Application program exception handling method, device, equipment and storage medium
CN114490324A (en) * 2021-12-22 2022-05-13 山东浪潮工业互联网产业股份有限公司 Gateway-based global exception handling method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108804299B (en) * 2017-04-26 2023-04-07 腾讯科技(深圳)有限公司 Application program exception handling method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104503918A (en) * 2015-01-12 2015-04-08 北京国双科技有限公司 Handling method and device for abnormal information
CN106708706A (en) * 2015-11-12 2017-05-24 北京国双科技有限公司 Task program exception alarm information processing method and apparatus
CN108304447A (en) * 2017-12-07 2018-07-20 北京趣拿软件科技有限公司 Processing method, device, storage medium and the processor of exception information
CN110275791A (en) * 2018-03-14 2019-09-24 普天信息技术有限公司 A kind of application exception processing method and processing device
CN108762966A (en) * 2018-06-05 2018-11-06 中国平安人寿保险股份有限公司 System exception hold-up interception method, device, computer equipment and storage medium
CN109981621A (en) * 2019-03-15 2019-07-05 厦门美图之家科技有限公司 Network request processing method and processing device
CN114371949A (en) * 2020-10-15 2022-04-19 腾讯科技(深圳)有限公司 Application program exception handling method, device, equipment and storage medium
CN113160024A (en) * 2021-04-30 2021-07-23 中国银行股份有限公司 Business management system and method based on micro-service architecture
CN113778985A (en) * 2021-08-19 2021-12-10 上海东普信息科技有限公司 Microservice architecture monitoring method, microservice architecture monitoring device, computer equipment and storage medium
CN114490324A (en) * 2021-12-22 2022-05-13 山东浪潮工业互联网产业股份有限公司 Gateway-based global exception handling method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Java Web应用中错误和异常处理方法研究;张语涵;刘淑华;周永鑫;;现代计算机(专业版);20130815(第23期);61-65 *
王江林 ; 向忠清 ; .基于微服务架构的服务容错分析与实现.自动化技术与应用.2020,(第03期), *

Also Published As

Publication number Publication date
CN114996098A (en) 2022-09-02

Similar Documents

Publication Publication Date Title
CN108900353B (en) Fault warning method and terminal equipment
CN113238913A (en) Intelligent server fault pushing method, device, equipment and storage medium
CN107294808A (en) The methods, devices and systems of interface testing
CN114996098B (en) Exception handling method and device
CN110442502B (en) Point burying method, device, equipment and storage medium
CN110083439B (en) Distributed transaction system
CN110858166B (en) Processing method and device for application exception, storage medium and processor
CN110806960A (en) Information processing method and device and terminal equipment
CN109428682B (en) Message processing confirmation method and device
CN110908708B (en) Code release method, device and system
CN109714214B (en) Server exception handling method and management equipment
CN111897789B (en) Log generation method and device
CN114500249B (en) Root cause positioning method and device
CN108111328A (en) A kind of abnormality eliminating method and device
CN115525568A (en) Code coverage rate inspection method and device, computer equipment and storage medium
CN113656003A (en) Software package management method and related equipment
CN115587046A (en) Code exception processing method and device, storage medium and computer equipment
CN111680974B (en) Method and device for positioning problems of electronic underwriting process
CN114416560A (en) Program crash analysis aggregation method and system
CN114154155B (en) Target program generation method, lux program detection device and equipment
CN112532478B (en) Link relation tracking method, system, checking method, device and equipment
CN113778789A (en) Alarm information processing method and device
CN114819956A (en) Transaction verification method and device, electronic equipment and storage medium
CN114741227A (en) Method and device for repairing program fault and electronic equipment
CN114118934A (en) Equipment point inspection abnormity flow conversion method, system, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant