github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/framework/cache/error_code.go (about) 1 // The package is migrated from beego, you can get from following link: 2 // import( 3 // "github.com/beego/beego/v2/client/cache" 4 // ) 5 // Copyright 2023. All Rights Reserved. 6 // 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // 13 // Unless required by applicable law or agreed to in writing, software 14 // distributed under the License is distributed on an "AS IS" BASIS, 15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 // See the License for the specific language governing permissions and 17 // limitations under the License. 18 19 package cache 20 21 import ( 22 "github.com/mdaxf/iac/framework/berror" 23 ) 24 25 var NilCacheAdapter = berror.DefineCode(4002001, moduleName, "NilCacheAdapter", ` 26 It means that you register cache adapter by pass nil. 27 A cache adapter is an instance of Cache interface. 28 `) 29 30 var DuplicateAdapter = berror.DefineCode(4002002, moduleName, "DuplicateAdapter", ` 31 You register two adapter with same name. In beego cache module, one name one adapter. 32 Once you got this error, please check the error stack, search adapter 33 `) 34 35 var UnknownAdapter = berror.DefineCode(4002003, moduleName, "UnknownAdapter", ` 36 Unknown adapter, do you forget to register the adapter? 37 You must register adapter before use it. For example, if you want to use redis implementation, 38 you must import the cache/redis package. 39 `) 40 41 var IncrementOverflow = berror.DefineCode(4002004, moduleName, "IncrementOverflow", ` 42 The increment operation will overflow. 43 `) 44 45 var DecrementOverflow = berror.DefineCode(4002005, moduleName, "DecrementOverflow", ` 46 The decrement operation will overflow. 47 `) 48 49 var NotIntegerType = berror.DefineCode(4002006, moduleName, "NotIntegerType", ` 50 The type of value is not (u)int (u)int32 (u)int64. 51 When you want to call Incr or Decr function of Cache API, you must confirm that the value's type is one of (u)int (u)int32 (u)int64. 52 `) 53 54 var InvalidFileCacheDirectoryLevelCfg = berror.DefineCode(4002007, moduleName, "InvalidFileCacheDirectoryLevelCfg", ` 55 You pass invalid DirectoryLevel parameter when you try to StartAndGC file cache instance. 56 This parameter must be a integer, and please check your input. 57 `) 58 59 var InvalidFileCacheEmbedExpiryCfg = berror.DefineCode(4002008, moduleName, "InvalidFileCacheEmbedExpiryCfg", ` 60 You pass invalid EmbedExpiry parameter when you try to StartAndGC file cache instance. 61 This parameter must be a integer, and please check your input. 62 `) 63 64 var CreateFileCacheDirFailed = berror.DefineCode(4002009, moduleName, "CreateFileCacheDirFailed", ` 65 Beego failed to create file cache directory. There are two cases: 66 1. You pass invalid CachePath parameter. Please check your input. 67 2. Beego doesn't have the permission to create this directory. Please check your file mode. 68 `) 69 70 var InvalidFileCachePath = berror.DefineCode(4002010, moduleName, "InvalidFilePath", ` 71 The file path of FileCache is invalid. Please correct the config. 72 `) 73 74 var ReadFileCacheContentFailed = berror.DefineCode(4002011, moduleName, "ReadFileCacheContentFailed", ` 75 Usually you won't got this error. It means that Beego cannot read the data from the file. 76 You need to check whether the file exist. Sometimes it may be deleted by other processes. 77 If the file exists, please check the permission that Beego is able to read data from the file. 78 `) 79 80 var InvalidGobEncodedData = berror.DefineCode(4002012, moduleName, "InvalidEncodedData", ` 81 The data is invalid. When you try to decode the invalid data, you got this error. 82 Please confirm that the data is encoded by GOB correctly. 83 `) 84 85 var GobEncodeDataFailed = berror.DefineCode(4002013, moduleName, "GobEncodeDataFailed", ` 86 Beego could not encode the data to GOB byte array. In general, the data type is invalid. 87 For example, GOB doesn't support function type. 88 Basic types, string, structure, structure pointer are supported. 89 `) 90 91 var KeyExpired = berror.DefineCode(4002014, moduleName, "KeyExpired", ` 92 Cache key is expired. 93 You should notice that, a key is expired and then it may be deleted by GC goroutine. 94 So when you query a key which may be expired, you may got this code, or KeyNotExist. 95 `) 96 97 var KeyNotExist = berror.DefineCode(4002015, moduleName, "KeyNotExist", ` 98 Key not found. 99 `) 100 101 var MultiGetFailed = berror.DefineCode(4002016, moduleName, "MultiGetFailed", ` 102 Get multiple keys failed. Please check the detail msg to find out the root cause. 103 `) 104 105 var InvalidMemoryCacheCfg = berror.DefineCode(4002017, moduleName, "InvalidMemoryCacheCfg", ` 106 The config is invalid. Please check your input. It must be a json string. 107 `) 108 109 var InvalidMemCacheCfg = berror.DefineCode(4002018, moduleName, "InvalidMemCacheCfg", ` 110 The config is invalid. Please check your input, it must be json string and contains "conn" field. 111 `) 112 113 var InvalidMemCacheValue = berror.DefineCode(4002019, moduleName, "InvalidMemCacheValue", ` 114 The value must be string or byte[], please check your input. 115 `) 116 117 var InvalidRedisCacheCfg = berror.DefineCode(4002020, moduleName, "InvalidRedisCacheCfg", ` 118 The config must be json string, and has "conn" field. 119 `) 120 121 var InvalidSsdbCacheCfg = berror.DefineCode(4002021, moduleName, "InvalidSsdbCacheCfg", ` 122 The config must be json string, and has "conn" field. The value of "conn" field should be "host:port". 123 "port" must be a valid integer. 124 `) 125 126 var InvalidSsdbCacheValue = berror.DefineCode(4002022, moduleName, "InvalidSsdbCacheValue", ` 127 SSDB cache only accept string value. Please check your input. 128 `) 129 130 var InvalidLoadFunc = berror.DefineCode(4002023, moduleName, "InvalidLoadFunc", ` 131 Invalid load function for read-through pattern decorator. 132 You should pass a valid(non-nil) load function when initiate the decorator instance. 133 `) 134 135 var LoadFuncFailed = berror.DefineCode(4002024, moduleName, "LoadFuncFailed", ` 136 Failed to load data, please check whether the loadfunc is correct 137 `) 138 139 var InvalidInitParameters = berror.DefineCode(4002025, moduleName, "InvalidInitParameters", ` 140 Invalid init cache parameters. 141 You can check the related function to confirm that if you pass correct parameters or configure to initiate a Cache instance. 142 `) 143 144 var PersistCacheFailed = berror.DefineCode(4002026, moduleName, "PersistCacheFailed", ` 145 Failed to execute the StoreFunc. 146 Please check the log to make sure the StoreFunc works for the specific key and value. 147 `) 148 149 var DeleteFileCacheItemFailed = berror.DefineCode(5002001, moduleName, "DeleteFileCacheItemFailed", ` 150 Beego try to delete file cache item failed. 151 Please check whether Beego generated file correctly. 152 And then confirm whether this file is already deleted by other processes or other people. 153 `) 154 155 var MemCacheCurdFailed = berror.DefineCode(5002002, moduleName, "MemCacheError", ` 156 When you want to get, put, delete key-value from remote memcache servers, you may get error: 157 1. You pass invalid servers address, so Beego could not connect to remote server; 158 2. The servers address is correct, but there is some net issue. Typically there is some firewalls between application and memcache server; 159 3. Key is invalid. The key's length should be less than 250 and must not contains special characters; 160 4. The response from memcache server is invalid; 161 `) 162 163 var RedisCacheCurdFailed = berror.DefineCode(5002003, moduleName, "RedisCacheCurdFailed", ` 164 When Beego uses client to send request to redis server, it failed. 165 1. The server addresses is invalid; 166 2. Network issue, firewall issue or network is unstable; 167 3. Client failed to manage connection. In extreme cases, Beego's redis client didn't maintain connections correctly, for example, Beego try to send request via closed connection; 168 4. The request are huge and redis server spent too much time to process it, and client is timeout; 169 170 In general, if you always got this error whatever you do, in most cases, it was caused by network issue. 171 You could check your network state, and confirm that firewall rules are correct. 172 `) 173 174 var InvalidConnection = berror.DefineCode(5002004, moduleName, "InvalidConnection", ` 175 The connection is invalid. Please check your connection info, network, firewall. 176 You could simply uses ping, telnet or write some simple tests to test network. 177 `) 178 179 var DialFailed = berror.DefineCode(5002005, moduleName, "DialFailed", ` 180 When Beego try to dial to remote servers, it failed. Please check your connection info and network state, server state. 181 `) 182 183 var SsdbCacheCurdFailed = berror.DefineCode(5002006, moduleName, "SsdbCacheCurdFailed", ` 184 When you try to use SSDB cache, it failed. There are many cases: 185 1. servers unavailable; 186 2. network issue, including network unstable, firewall; 187 3. connection issue; 188 4. request are huge and servers spent too much time to process it, got timeout; 189 `) 190 191 var SsdbBadResponse = berror.DefineCode(5002007, moduleName, "SsdbBadResponse", ` 192 The response from SSDB server is invalid. 193 Usually it indicates something wrong on server side. 194 `) 195 196 var DeleteFailed = berror.DefineCode(5002008, moduleName, "DeleteFailed", ` 197 Beego attempt to delete cache item failed. Please check if the target key is correct. 198 `) 199 200 var ( 201 ErrKeyExpired = berror.Error(KeyExpired, "the key is expired") 202 ErrKeyNotExist = berror.Error(KeyNotExist, "the key isn't exist") 203 )