Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for displaying software error code information according to a first embodiment of the present invention. It should be noted that the method of the present invention is not limited to the flow sequence shown in fig. 1 if the results are substantially the same. As shown in fig. 1, the method comprises the steps of:
s10: a configuration file is generated for defining the error codes and the error information corresponding to the error codes.
The error code comprises a numerical value and an error type corresponding to the numerical value, and the numerical value is used for distinguishing different error types. When a software program runs and a functional error occurs in the software program, the software gives a numerical value and an error type corresponding to the numerical value. In general, the value in the error code is identified to the computer program, for example, the service layer may execute different logic applications according to different values, and thus the value must be unique. The error type can be used by an operator, and the operator can judge or analyze the reason of the error of the software program according to different error types. For example:
111SQLSTATE:HY000(SERVER_STORE_NOT_PERMISSION),
//111 is the error value and SERVER _ STORE _ NOT _ PERMISSION is the type of error.
Since the values and the error types included in the error codes are not easy to understand for the operator, in the configuration file of the embodiment, in addition to defining the error codes, error information corresponding to the error codes is further defined. The error information may include a short description and a detailed description, among others. The short description corresponds to the type of error provided by the system, while the detailed description is provided to specify possible causes of error occurrence. For example: the error code "111" corresponds to a short description of "file cannot be created", and a detailed description of "file cannot be created due to authority". Developers can manually write or automatically generate corresponding configuration files by tools, further define all error codes and error information corresponding to the error codes, and can manage and maintain all the error codes by modifying or adding the content of the configuration files. In this embodiment, the configuration file may be stored and used in an Extensible Markup Language (XML) file, or in other application scenarios, another file format in which the error codes and the error information corresponding to the error codes may be classified and stored may be used as the configuration file.
S11: and automatically generating a localization language file according to the configuration file.
Since the operators are from different countries and may only use one of the languages when writing the configuration file, in order to enable people of different languages to understand the description content in the error information, the corresponding error description information needs to be displayed in different language environments, such as simplified chinese error description information, and french error description information, in french environments, the localized language file needs to be automatically generated according to the configuration file.
S12: and automatically generating an error code prompt file corresponding to the development tool of the software according to the localized language file.
Because different software development tools correspond to different generated codes and different codes correspond to different grammar rules, in the present invention, in order to enable the localized language file generated in step S11 to be used in all development environments corresponding to software, a code scheme needs to be designed, that is, different error code prompt files are automatically generated for different development languages, so that when a program runs, error information corresponding to an error code can be displayed by reading the error code prompt files. For example, in the C/C + + programming environment, the error code presentation file corresponding to the C language is automatically generated using the syntax and the rule corresponding to the C language, and in the Java programming environment, the error code presentation file corresponding to the Java language is automatically generated using the syntax and the rule corresponding to the Java language.
Taking a Java program as an example, a method for generating a corresponding error code hint file in the Java program is illustrated as follows:
s13: and compiling a software development tool to obtain a software program containing the error code prompt file.
S14: and running the software program, and when the software program has a running error, displaying the error code and the error information corresponding to the error code according to the error code prompt file of the software program, wherein the error information corresponding to the displayed error code is matched with the running place and the running environment of the software.
In the software running process, when the running program has errors, the system accesses an error code prompt file in the software program, finds error information corresponding to the error code by searching the corresponding error code in the file, and displays the error code and the error information corresponding to the error code on a terminal interface for running the program so as to provide reference for an operator. And displaying error information of different languages according to the running positions and running environments of different software. Such as: on the chinese operating system, "111 _ unable to create file" may result in inability to create file due to authority "is displayed," 111_ NOT _ policy _ NOT PERMISSION "is displayed on the english operating system.
By the method, the detailed error codes of different languages and the error information corresponding to the error codes can be displayed under different environments of software operation, and the working efficiency is improved.
Referring to fig. 2, fig. 2 is a flowchart illustrating a second embodiment of the method for displaying software error code information according to the present invention, wherein step S10 further includes the following steps:
s201: and grouping and managing the error codes according to different types, wherein each error code corresponds to a unique identifier.
S202: the error codes correspond to the error information one by one.
In order to facilitate management and maintenance of all error codes and error information corresponding to the error codes by developers, all error codes need to be grouped and managed according to different types. For example, the value of an error code belongs to class a, and may be further divided into class a1, class a2, class A3 … …, and the like on the basis of class a1, class a11, class a12 … …, and the like, and so on, and may be divided multiple times, but in the value divided by each level, it is necessary to ensure that all values are unique and cannot be the same as other values, such as: a _ A1_ A11_1, A _ A1_ A11_2 or A _ A1_ A12_1, A _ A1_ A12_2, etc. The values in the error code must correspond one-to-one to the error type.
In one application scenario, an XML file is taken as an example to generate a configuration file for defining an error code and error information corresponding to the error code.
Top level nodes error: for describing the start of the configuration;
module node: all error codes for describing a type for which all error values and error type definitions must be stored under the module;
the attribute id of the module node is a numerical value corresponding to the error code, and the id needs to be unique under the father node of the module node;
the attribute code of the module node is the error type corresponding to the error code, and the code needs to be unique under the father node of the module node;
error: describing a specific error message;
attribute id of error node: the numerical value corresponding to the error code must be a globally unique numerical value;
attribute code of error node: the error type corresponding to the error code must be globally unique;
content of error child node msg: short default error description information;
content of error child node desc: possible causes of detailed error occurrence;
the module node and the error node may have a plurality of sub-nodes, that is, the module node may include a plurality of module sub-nodes and error sub-nodes, and the error node may include a plurality of error sub-nodes and module sub-nodes, so as to classify, store and manage all error codes.
The following error codes and error information corresponding to the error codes can be obtained through the application scenario, so that the error codes correspond to the error information one by one:
111_ SERVER _ STORE _ NOT _ permaission: "file cannot be created", "file cannot be created due to authority";
112_ SERVER _ STORE _ NOT _ FOUND: "No file found", "file cannot be found" either because there is no read permission or because there is no file.
By the method, all error codes can be classified and stored, so that operators can conveniently search and maintain all error code information in the configuration file, and the working efficiency is improved.
Referring to fig. 3, fig. 3 is a flowchart illustrating a method for displaying software error code information according to a third embodiment of the present invention. Step S11 further includes the steps of:
s301: and translating the configuration file into the language of the running environment corresponding to the software, and naming the configuration file by using the international standard code and the country code of the language of the running environment.
S302: a default localized language file is generated that can run in all language contexts.
In this embodiment, in order to enable people of different languages to understand the error description information corresponding to the error code in the configuration file, the configuration file needs to be translated into languages of different countries, for example, in a simplified chinese environment, the error information described in simplified chinese is displayed; in the english environment, error information of english description is displayed. In the implementation process, the original configuration files are translated into languages of different countries through translation software, and the configuration files are named by international standard codes and country codes, so that other programs can conveniently search the corresponding configuration files. For example: simplified Chinese is named as: properties, english file named: properties, en _ us.
In one application scenario, in order to facilitate the development program to read the error code and the error description corresponding to the error code, the error description in the storage file may be displayed in a type of a character string, for example:
property file, show one certain error description:
SERVER _ STORE _ NOT _ policy ═ s no authority% s
SERVER STORE NOT FOUND file% s
In the en _ us. properties document, a certain error description is displayed:
SERVER_STORE_NOT_PERMISSION=%snot permission%s
SERVER_STORE_NOT_FOUND=not found%s
in another embodiment, a default common configuration file may be generated as the localization language file, and when the software runs and no localization file corresponding to the language of the software is found, the default common configuration file may be used as the configuration file, and the error description information may be obtained from the default common configuration file. This file is named "default. For example: the program runs under a French system, the local file does not have a localization file corresponding to French, a default file can be used when the program runs, if the localization file corresponding to French is newly added to a subsequent program, the program automatically selects the localization file corresponding to French when the program runs next time, corresponding description information is read from the file, and the software program does not need to be modified. In order to facilitate the software program to accurately identify the error codes in the configuration file and the error information corresponding to the error codes in the software development process, when the localization file is generated, a row of codes may be generated for each error description information, and in the row of codes, the identifier corresponding to the error description information is unique.
For example: SERVER _ STORE _ NOT _ PERMISSION%
By the method, the corresponding localized language file can be generated in any software development environment, and the corresponding error code prompt file can be further generated. When the localization language file required to be used does not exist, the default file can be used for operation.
Fig. 4 is a schematic flowchart of a fourth embodiment of the method for displaying software error code information according to the present invention, as shown in fig. 4, the method further includes the following steps:
s40: and automatically generating a description document of the error code according to the configuration file.
S41: and compiling a software development tool to obtain a software program containing the description document of the error codes.
S42: and operating the software program, and checking the description document of the error code in the description document of the software program.
In order to enable a user to inquire error values and error information of all error codes in the using process of a program, an error code description document can be added in a software description document for describing various generated errors in detail, so that the user can refer to and view the errors conveniently. In the compiling process, reading the configuration file to generate a corresponding description document, wherein the document comprises: error code number, error code type, error information, and detailed error interpretation. As shown in table 1:
TABLE 1
In this embodiment, the error information may be generated by using an extended stylesheet language transformation (XSLT), or may be generated by using other generation methods, which is not limited herein.
By the method, an operator can conveniently check the description document in the software program, so that the error information and the detailed explanation corresponding to the error code can be quickly inquired, and the working efficiency is improved.
Referring to fig. 5, fig. 5 is a flowchart illustrating a software error code information system according to a first embodiment of the present invention. In this embodiment, the system includes: a configuration module 51, a translation module 52, an encoding module 53, a first compiling module 54 and a first running module 55.
The configuration module 51: the configuration file is used for generating a configuration file used for defining error codes and error information corresponding to the error codes;
the translation module 52: the system is used for automatically generating a localization language file according to the configuration file;
the encoding module 53: the system comprises a localization language file, a code generation module and a code generation module, wherein the localization language file is used for automatically generating an error code prompt file corresponding to a development tool of software according to the localization language file;
the first compiling module 54: and compiling a software development tool to obtain a software program containing the error code prompt file.
The first operation module 55: the software program display method is used for operating the software program, when the software program has an operation error, the error code and the error information corresponding to the error code are displayed according to the error code prompt file of the software program, and the displayed error information corresponding to the error code is matched with the operation place and the operation environment of the software.
The configuration module 51 is specifically configured to perform grouping management on error codes according to different types, where each error code corresponds to a unique identifier; the error codes correspond to the error information one by one.
The translation module 52 is specifically configured to translate the configuration file into a language of an operating environment corresponding to the software, and name the configuration file by using an international standard code and a country code of the language of the operating environment; a default localized language file is generated that can run in all language contexts.
Wherein, the configuration file is an XML file.
FIG. 6 is a flowchart illustrating a second embodiment of the software error code information displaying system according to the present invention, further comprising: a generating module 61, a second compiling module 62 and a second running module 63.
The generation module 61: the description document is used for automatically generating error codes according to the configuration file;
the second compiling module 62: a software program for compiling a development tool for the software to obtain a specification document containing error codes;
the second operation module 63: and operating the software program, and checking the description document of the error code in the description document of the software program.
Each module and unit in this embodiment can respectively execute the corresponding steps in the above method embodiments, so that the description of each module is omitted here, and please refer to the description of the corresponding steps above in detail.
In the several embodiments provided in the present invention, it should be understood that the disclosed system, and method, may be implemented in other ways. For example, the division of the modules or units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.