Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for displaying abnormal information of a code, which can determine a first abnormal item of the code when monitoring that the code runs abnormally, determine first abnormal information corresponding to the first abnormal item according to an abnormal configuration file, and display the first abnormal information in a plaintext form; the abnormal configuration file comprises a plurality of second abnormal items and second abnormal information in a plaintext form, wherein the second abnormal information corresponds to the second abnormal items respectively, so that the problem of the program is intuitively displayed in the plaintext form, and the efficiency of the developer in troubleshooting the problem is improved.
In order to achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an anomaly information display method of a code.
The method for displaying the abnormal information of the code comprises the following steps:
 Monitoring the running of codes;
 when the code runs abnormally, determining a first abnormal item of the code;
 Determining first abnormal information corresponding to a first abnormal item according to the abnormal configuration file; the exception configuration file includes: a plurality of second abnormal items and second abnormal information in a plaintext form corresponding to the plurality of second abnormal items, respectively;
 the first anomaly information is presented in plain text.
Alternatively, the process may be carried out in a single-stage,
The plurality of second outlier items correspond to different levels;
 Determining first anomaly information corresponding to a first anomaly item, including:
 searching a second abnormal item of the highest level corresponding to the category in the abnormal configuration file according to the category to which the first abnormal item belongs;
 and determining whether the second abnormal item of the highest level has a lower level item or not, and if not, taking second abnormal information corresponding to the second abnormal item of the highest level as first abnormal information.
Alternatively, the process may be carried out in a single-stage,
When it is determined that the second abnormal item of the highest hierarchy exists in the lower-level items, the method further includes:
 Determining a lower item corresponding to the first abnormal item from the lower items of the second abnormal item according to the abnormal field in the first abnormal item;
 and taking the second abnormal information corresponding to the determined subordinate item as the first abnormal information.
Alternatively, the process may be carried out in a single-stage,
The exception configuration file includes one or more language versions, the method further comprising:
 Determining the language of the code running environment, determining the language version of the abnormal configuration file according to the language of the running environment, and displaying the first abnormal information according to the determined language version.
Alternatively, the process may be carried out in a single-stage,
The number of the abnormal configuration files is multiple, and the abnormal configuration files are stored in the online server;
 After determining the first exception item of the code, comprising:
 According to the first abnormal item, downloading an abnormal configuration file corresponding to the first abnormal item from the online server to the local, and determining first abnormal information corresponding to the first abnormal item according to the downloaded abnormal configuration file.
Alternatively, the process may be carried out in a single-stage,
The abnormal configuration file is stored in the online server;
 After determining the first exception item of the code, comprising:
 Acquiring a second abnormal item corresponding to the first abnormal item and second abnormal information corresponding to the second abnormal item from an abnormal configuration file of the online server according to the first abnormal item;
 and generating and displaying the first abnormal information according to the second abnormal information.
Alternatively, the process may be carried out in a single-stage,
The first anomaly information includes any one or more of: anomaly encoding, anomaly description information in plaintext form, and anomaly resolution policies in plaintext form.
In order to achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided an abnormality information presentation apparatus of a code.
The abnormal information display device of the code comprises a monitoring module, an abnormal item determining module, an abnormal information determining module and a display module; wherein:
 the monitoring module is used for monitoring the running of the codes;
 the abnormal item determining module is used for determining a first abnormal item of the code when the code runs abnormally;
 The abnormal information determining module is used for determining first abnormal information corresponding to the first abnormal item according to the abnormal configuration file; the exception configuration file includes: a plurality of second abnormal items and second abnormal information in a plaintext form corresponding to the plurality of second abnormal items, respectively;
 And the display module is used for displaying the first abnormal information in a plaintext form.
In order to achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided an abnormality information presentation electronic device of a code.
The electronic equipment for displaying the abnormal information of the code comprises: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the abnormal information display method of the code.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention has stored thereon a computer program that, when executed by a processor, implements an abnormal information presentation method of a code of the embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: when monitoring that the code runs abnormally, a first abnormal item of the code can be determined, and according to an abnormal configuration file, first abnormal information corresponding to the first abnormal item is determined and displayed in a plaintext form; the abnormal configuration file comprises a plurality of second abnormal items and second abnormal information in a plaintext form, wherein the second abnormal information corresponds to the second abnormal items respectively, so that the problem of the program is intuitively displayed in the plaintext form, and the efficiency of the developer in troubleshooting the problem is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features in the embodiments may be combined with each other without collision.
Fig. 1 is a schematic diagram of main steps of a code anomaly information presentation method according to an embodiment of the present invention.
As shown in fig. 1, the method for displaying abnormal information of a code according to an embodiment of the present invention mainly includes the following steps:
 step S101: the running of the code is monitored.
Step S102: when the code runs abnormally, a first abnormal item of the code is determined.
In an embodiment of the present invention, the first exception item of the code may be one or more captured statements of exceptions of the code during the running process. Wherein, each abnormal statement may contain an abnormal field, and the abnormal field may be the missing of a field, the redundancy of a field or the assignment of the field is inconsistent with the type of the field, etc.
Step S103: determining first abnormal information corresponding to a first abnormal item according to the abnormal configuration file; the exception configuration file includes: the plurality of second abnormal items and the plurality of second abnormal items correspond to the second abnormal information in the plaintext form respectively.
In the embodiment of the invention, when the code operation is abnormal and the information corresponding to the abnormality needs to be reported, the corresponding first abnormality information can be determined according to the first abnormality item of the code. In a preferred embodiment of the present invention, the first exception information may be passed to the caller of the information through ErrorMessage objects, errorMessage objects may be generated by the exception factory class, i.e., class ErrorMessageFactory, and specifically, class ErrorMessageFactory may construct ErrorMessage objects by a set of static methods in the corresponding class ErrorMessageBuilder, i.e., operation MessageResourceAccessor, to reduce the complexity of constructing various types of first exception information.
In the embodiment of the invention, the first abnormal item and the first abnormal information corresponding to the first abnormal item are recorded in an abnormal configuration file, and the abnormal configuration file can be stored in an online server or can be stored locally. The exception configuration file includes: a plurality of second abnormal items, and second abnormal information in a plain text form corresponding to the second abnormal items, respectively. When the code is running abnormally and the first abnormal item is captured, the first abnormal information corresponding to the first abnormal item can be hit from the plurality of pieces of second abnormal information of the abnormal configuration file according to the first abnormal item.
For example, the content of one exception configuration file may be:
 Account.add-business-error \ AccountIsExistError = failure to add account number, current pin: [ {0} ] already exists;
 Load-business-error \ PinNotExistError = object failure to load account, current pin: [ {0} ] does not exist;
 Account.changeParent-business-error \ PinNotExistError = update parent pin failed, currently parent pin: [ {0} ] does not exist.
Wherein the second abnormal item Account.add-business-error corresponds to second abnormal information that the account number fails to be added and the current pin: [ {0} ] already exists; the second abnormal item Account.load-business-error is corresponding to second abnormal information, namely 'the object failure of loading account number, and the current pin: [ {0} ] does not exist'. When capturing the first abnormal item Account, add-business-error, the corresponding first abnormal information of "failure to add account number" is hit from the abnormal configuration file, and the current pin: [ {0} ] already exists.
In the embodiment of the invention, the second abnormal items in the abnormal configuration file can adopt a hierarchical structure design, namely, a plurality of second abnormal items correspond to different levels, and the higher the level is, the coarser granularity of second abnormal information obtained by analyzing the second abnormal items is; the lower the hierarchy, the finer the granularity of the second anomaly information resulting from the analysis of the second anomaly item.
Therefore, in the embodiment of the present invention, after determining the first abnormal item of the code, as shown in fig. 2, fig. 2 is a schematic diagram of main steps of a method for determining the first abnormal information corresponding to the first abnormal item according to an embodiment of the present invention, where the method mainly includes the following steps:
 step S201: searching a second abnormal item of the highest level corresponding to the class in the abnormal configuration file according to the class to which the first abnormal item belongs;
 step S202: determining whether the second abnormal item of the highest hierarchy has a lower item, if not, executing step S203, and if yes, executing steps S204-S205;
 Step S203: taking second abnormal information corresponding to the second abnormal item of the highest level as first abnormal information;
 step S204: determining a lower item corresponding to the first abnormal item from the lower items of the second abnormal item according to the abnormal field in the first abnormal item;
 step S205: and taking the second abnormal information corresponding to the determined subordinate item as the first abnormal information.
In a preferred embodiment of the present invention, the second exception item in the exception configuration file corresponds to two levels, and thus the corresponding second exception information also includes two levels, namely a main exception portion and a sub exception portion. Wherein each sub-exception corresponds to a main exception, and each main exception may have several seed exceptions. Wherein the main anomaly part and the sub anomaly part of the second anomaly information can comprise any one or more of the following: anomaly encoding, anomaly description information in plaintext form, and anomaly resolution policies in plaintext form. When the main exception portion and/or the sub exception portion of the second exception information includes both the exception code and the exception description information in the plaintext form, the exception code and the exception description information in the plaintext form may be saved in the exception configuration file in the form of a key value pair.
For example, the content of one exception configuration file may be:
 the main exception code in the second exception information is 7, which represents that the necessary filling parameter is not needed, and the exception description information message in the plaintext form also prompts the "the necessary filling parameter is not needed" so as to facilitate the developer to check the problem, and the exception solving strategy solution in the plaintext form is a processing plan proposed for the exception, and prompts the "please add the necessary filling parameter according to the description of the interface document so as to facilitate the developer to solve the problem. subErrors is a sub-anomaly information list, which contains two sub-anomalies, respectively: lack of parameters locale and lack of parameters pin. The sub-exception code is a character string for performing hierarchical coding according to the main exception type, such as a missing-parameter:6x, a 6 x-non-exist: invalid-7y, wherein 6x,7y are occupied fields, and can be replaced by corresponding exception fields according to specific exceptions.
In a preferred embodiment of the present invention, the exception configuration file provides a default framework DefaltErrorMessage for the second exception item, in which 13 master exceptions are defined, covering all possible master exception types, with the master exception portion not supporting extensions; the main exception type is a sub exception part support extension of business exception, and can be defined by a calling party by self, and the defined sub exception information is configured into an exception configuration file.
In the embodiment of the invention, the abnormal configuration file can also comprise one or more language versions, and the abnormal configuration file corresponding to each language version is respectively packaged and stored. When the code is abnormal in operation, the language of the code operation environment can be determined first, then the language version of the abnormal configuration file is determined according to the language of the operation environment, and the first abnormal information is displayed according to the determined language version, so that the application scene of the scheme is expanded, and the developer can read the first abnormal information conveniently.
In the embodiment of the invention, when a plurality of abnormal configuration files are stored in the online server, after the first abnormal item of the code is determined, the resource loader downloads the abnormal configuration file corresponding to the first abnormal item from the online server to the local according to the first abnormal item, and then the resource accessor determines the first abnormal information corresponding to the first abnormal item according to the downloaded abnormal configuration file. Specifically, the bottom layer of the loading of the abnormal configuration file by the resource loader is realized based on a java. Uteil. Resource bundle class provided by the JDK, the core realization of the processing of the abnormal configuration file is PropertyBundleMessageResource class, the class utilizes java. Uteil. Resource bundle to realize the loading of the abnormal configuration file, caches and manages the abnormal configuration file, and supports the management of the abnormal configuration files of multiple language versions; the resource accessor instantiates a MessageResource object through MessageResourceAccessor of the access tool class, and accesses the second exception item and the second exception information downloaded to the local exception configuration file through GETMESSAGE public method.
In the embodiment of the invention, when the abnormal configuration file is stored in the online server, the abnormal configuration file can also be directly traversed on the online server to hit the second abnormal information. Specifically: after determining the first abnormal item of the code, the second abnormal item corresponding to the first abnormal item and the second abnormal information corresponding to the second abnormal item can be obtained from the abnormal configuration file of the online server according to the first abnormal item, and the first abnormal information is generated and displayed according to the second abnormal information.
In an embodiment of the present invention, the first anomaly information may include any one or more of the following: anomaly encoding, anomaly description information in plaintext form, and anomaly resolution policies in plaintext form.
Step S104: the first anomaly information is presented in plain text.
In the embodiment of the invention, the first abnormal information is displayed in a plaintext form, so that the problem of code is intuitively displayed, and the efficiency of the developer in troubleshooting the problem is further improved.
According to the method for displaying the abnormal information of the code, which is disclosed by the embodiment of the invention, when the running abnormality of the code is monitored, a first abnormal item of the code can be determined, then according to an abnormal configuration file, first abnormal information corresponding to the first abnormal item is determined, and the first abnormal information is displayed in a plaintext form; the abnormal configuration file comprises a plurality of second abnormal items and second abnormal information in a plaintext form, wherein the second abnormal information corresponds to the second abnormal items respectively, so that the problem of the program is intuitively displayed in the plaintext form, and the efficiency of the developer in troubleshooting the problem is improved.
Fig. 3 is a schematic diagram of main modules of an abnormality information presentation apparatus of a code according to an embodiment of the present invention.
As shown in fig. 3, an apparatus 300 for displaying exception information of a code according to an embodiment of the present invention includes a monitor module 301, an exception item determination module 302, an exception information determination module 303, and a display module 304; wherein:
 a monitoring module 301, configured to monitor the running of the code;
 An abnormal item determining module 302, configured to determine a first abnormal item of the code when the code runs abnormally;
 An anomaly information determining module 303, configured to determine first anomaly information corresponding to a first anomaly item according to an anomaly configuration file; the exception configuration file includes: a plurality of second abnormal items and second abnormal information in a plaintext form corresponding to the plurality of second abnormal items, respectively;
 the display module 304 is configured to display the first anomaly information in a plaintext form.
In an embodiment of the present invention, the plurality of second abnormal items correspond to different levels; the anomaly information determination module 303 is further configured to: searching a second abnormal item of the highest level corresponding to the category in the abnormal configuration file according to the category to which the first abnormal item belongs; and determining whether the second abnormal item of the highest level has a lower level item or not, and if not, taking second abnormal information corresponding to the second abnormal item of the highest level as first abnormal information.
In the embodiment of the present invention, when it is determined that the second abnormal item of the highest hierarchy exists in the subordinate items, the abnormal information determining module 303 is further configured to: determining a lower item corresponding to the first abnormal item from the lower items of the second abnormal item according to the abnormal field in the first abnormal item; and taking the second abnormal information corresponding to the determined subordinate item as the first abnormal information.
In an embodiment of the present invention, the exception configuration file includes one or more language versions, and the exception information determining module 303 is further configured to: determining the language of the code running environment, determining the language version of the abnormal configuration file according to the language of the running environment, and displaying the first abnormal information according to the determined language version.
In the embodiment of the invention, a plurality of abnormal configuration files are provided, and the abnormal configuration files are stored in an online server; the anomaly information determination module 303 is further configured to: according to the first abnormal item, downloading an abnormal configuration file corresponding to the first abnormal item from the online server to the local, and determining first abnormal information corresponding to the first abnormal item according to the downloaded abnormal configuration file.
In the embodiment of the invention, the abnormal configuration file is stored in an online server; the anomaly information determination module 303 is further configured to: acquiring a second abnormal item corresponding to the first abnormal item and second abnormal information corresponding to the second abnormal item from an abnormal configuration file of the online server according to the first abnormal item; and generating and displaying the first abnormal information according to the second abnormal information.
In an embodiment of the present invention, the first anomaly information includes any one or more of: anomaly encoding, anomaly description information in plaintext form, and anomaly resolution policies in plaintext form.
According to the abnormal information display device of the code, when monitoring that the code runs abnormally, the abnormal information display device can determine the first abnormal item of the code, then determine the first abnormal information corresponding to the first abnormal item according to the abnormal configuration file, and display the first abnormal information in a plaintext form; the abnormal configuration file comprises a plurality of second abnormal items and second abnormal information in a plaintext form, wherein the second abnormal information corresponds to the second abnormal items respectively, so that the problem of the program is intuitively displayed in the plaintext form, and the efficiency of the developer in troubleshooting the problem is improved.
Fig. 4 illustrates an exemplary system architecture 400 of a method of exhibiting exception information of a code or an apparatus of exhibiting exception information of a code to which an embodiment of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and an electronic device 405. The network 404 is used as a medium to provide communication links between the terminal devices 401, 402, 403 and the electronic device 405. The network 404 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the electronic device 405 via the network 404 using the terminal devices 401, 402, 403 to receive or send messages or the like. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 401, 402, 403.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The electronic device 405 may be a server providing various services, such as a background management server providing support for shopping-type websites browsed by the user using the terminal devices 401, 402, 403. The background management server can analyze and other processing on the received data such as the product information inquiry request and the like, and feed back processing results (such as target push information and product information) to the terminal equipment.
It should be noted that, the method for displaying the code abnormal information provided in the embodiment of the present invention is generally executed by the electronic device 405, and accordingly, the device for displaying the code abnormal information is generally disposed in the electronic device 405.
It should be understood that the number of terminal devices, networks and electronic devices in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and electronic devices, as desired for implementation.
Referring now to FIG. 5, there is illustrated a schematic diagram of a computer system 500 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input section 506 including a keyboard, a mouse, and the like; an output portion 507 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker, and the like; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The drive 510 is also connected to the I/O interface 505 as needed. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as needed so that a computer program read therefrom is mounted into the storage section 508 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 509, and/or installed from the removable media 511. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 501.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor comprises a monitoring module, an abnormal item determining module, an abnormal information determining module and a display module. The names of these modules do not constitute a limitation on the module itself in some cases, for example, a snoop module may also be described as a "module for snooping the execution of code".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: monitoring the running of codes; when the code runs abnormally, determining a first abnormal item of the code; determining first abnormal information corresponding to a first abnormal item according to the abnormal configuration file; the exception configuration file includes: a plurality of second abnormal items and second abnormal information in a plaintext form corresponding to the plurality of second abnormal items, respectively; the first anomaly information is presented in plain text.
According to the technical scheme of the embodiment of the invention, when the running abnormality of the code is monitored, a first abnormal item of the code can be determined, and according to the abnormal configuration file, first abnormal information corresponding to the first abnormal item is determined and displayed in a plaintext form; the abnormal configuration file comprises a plurality of second abnormal items and second abnormal information in a plaintext form, wherein the second abnormal information corresponds to the second abnormal items respectively, so that the problem of the program is intuitively displayed in the plaintext form, and the efficiency of the developer in troubleshooting the problem is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.