From 9f096fc63d28e52550f94c7d9d87b27c60eaeb45 Mon Sep 17 00:00:00 2001 From: jflyfox Date: Fri, 30 Jul 2021 16:21:45 +0800 Subject: [PATCH] improve error code for package gerror --- errors/gerror/gerror_code.go | 41 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/errors/gerror/gerror_code.go b/errors/gerror/gerror_code.go index 6497b3003..055ea0ab0 100644 --- a/errors/gerror/gerror_code.go +++ b/errors/gerror/gerror_code.go @@ -9,17 +9,32 @@ package gerror // Reserved internal error code of framework: code < 1000. const ( - CodeNil = -1 // No error code specified. - CodeOk = 0 // It is OK without error. - CodeInternalError = 50 // An error occurred internally. - CodeValidationFailed = 51 // Data validation failed. - CodeDbOperationError = 52 // Database operation error. - CodeInvalidParameter = 53 // The given parameter for current operation is invalid. - CodeMissingParameter = 54 // Parameter for current operation is missing. - CodeInvalidOperation = 55 // The function cannot be used like this. - CodeInvalidConfiguration = 56 // The configuration is invalid for current operation. - CodeMissingConfiguration = 57 // The configuration is missing for current operation. - CodeNotImplemented = 58 // The operation is not implemented yet. - CodeNotSupported = 59 // The operation is not supported yet. - CodeOperationFailed = 60 // I tried, but I cannot give you what you want. + // =============================================================================== + // Common system codes. + // =============================================================================== + + CodeNil = -1 // No error code specified. + CodeOk = 0 // It is OK. + CodeInternalError = 50 + iota // An error occurred internally. + CodeValidationFailed // Data validation failed. + CodeDbOperationError // Database operation error. + CodeInvalidParameter // The given parameter for current operation is invalid. + CodeMissingParameter // Parameter for current operation is missing. + CodeInvalidOperation // The function cannot be used like this. + CodeInvalidConfiguration // The configuration is invalid for current operation. + CodeMissingConfiguration // The configuration is missing for current operation. + CodeNotImplemented // The operation is not implemented yet. + CodeNotSupported // The operation is not supported yet. + CodeOperationFailed // I tried, but I cannot give you what you want. + CodeNotAuthorized // Not Authorized. + CodeSecurityReason // Security Reason. + CodeServerBusy // Server is busy, please try again later. + CodeUnknown // Unknown error. + CodeResourceNotExist // Resource does not exist. + + // =============================================================================== + // Common business codes. + // =============================================================================== + + CodeBusinessValidationFailed = 300 + iota // Business validation failed. )