📄️ Error Code - Example
In the GoFrame framework, the NewCode and WrapCode methods are used for error handling, allowing the creation and wrapping of error objects with custom error codes and stack information. This document provides example code based on the GoFrame framework to help developers better understand the application of error codes in programs.
📄️ Error Code - Interface
The error code interface in the GoFrame framework is used for error handling, primarily describing the interface design and high scalability of the error code component gcode. By implementing the Code interface, developers can customize error codes. The framework provides a default implementation, but developers can also extend and implement their own error code logic as needed.
📄️ Error Code - Extension
Error handling in the GoFrame framework, especially the extension of error codes. By using the Detail parameter of error codes, error codes can be customized according to business needs. In specific scenarios, we can flexibly create new error codes using the WithCode method and apply and handle them in middleware. This solution not only enhances the flexibility of business logic but also provides detailed error information for upper layers.
📄️ Error Code - Implementation
Custom implementation of business error codes in the GoFrame framework. By implementing the gcode.Code interface, complex error codes can be defined; code examples for error handling are provided, showing how to use custom error codes in conjunction with middleware.
📄️ Error Code - Built-in Codes
Common built-in error codes provided by the GoFrame framework for developers to use directly. Note that business-used integer error codes should be defined greater than 1000 to avoid conflict with framework-reserved error codes. A link to the error code definition file is provided to help developers better handle and use error codes.