github.com/matrixorigin/matrixone@v0.7.0/pkg/common/moerr/error_no_ctx.go (about) 1 // Copyright 2021 - 2022 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package moerr 16 17 import ( 18 "encoding/hex" 19 "fmt" 20 ) 21 22 func NewInfoNoCtx(msg string) *Error { 23 return newError(Context(), ErrInfo, msg) 24 } 25 26 func NewBadS3ConfigNoCtx(msg string) *Error { 27 return newError(Context(), ErrBadS3Config, msg) 28 } 29 30 func NewInternalErrorNoCtx(msg string, args ...any) *Error { 31 xmsg := fmt.Sprintf(msg, args...) 32 return newError(Context(), ErrInternal, xmsg) 33 } 34 35 func NewNYINoCtx(msg string, args ...any) *Error { 36 xmsg := fmt.Sprintf(msg, args...) 37 return newError(Context(), ErrNYI, xmsg) 38 } 39 40 func NewNotSupportedNoCtx(msg string, args ...any) *Error { 41 xmsg := fmt.Sprintf(msg, args...) 42 return newError(Context(), ErrNotSupported, xmsg) 43 } 44 45 func NewOOMNoCtx() *Error { 46 return newError(Context(), ErrOOM) 47 } 48 49 func NewDivByZeroNoCtx() *Error { 50 return newError(Context(), ErrDivByZero) 51 } 52 53 func NewOutOfRangeNoCtx(typ string, msg string, args ...any) *Error { 54 xmsg := fmt.Sprintf(msg, args...) 55 return newError(Context(), ErrOutOfRange, typ, xmsg) 56 } 57 58 func NewDataTruncatedNoCtx(typ string, msg string, args ...any) *Error { 59 xmsg := fmt.Sprintf(msg, args...) 60 return newError(Context(), ErrDataTruncated, typ, xmsg) 61 } 62 63 func NewInvalidArgNoCtx(arg string, val any) *Error { 64 return newError(Context(), ErrInvalidArg, arg, fmt.Sprintf("%v", val)) 65 } 66 67 func NewBadConfigNoCtx(msg string, args ...any) *Error { 68 xmsg := fmt.Sprintf(msg, args...) 69 return newError(Context(), ErrBadConfig, xmsg) 70 } 71 72 func NewInvalidInputNoCtx(msg string, args ...any) *Error { 73 xmsg := fmt.Sprintf(msg, args...) 74 return newError(Context(), ErrInvalidInput, xmsg) 75 } 76 77 func NewSyntaxErrorNoCtx(msg string, args ...any) *Error { 78 xmsg := fmt.Sprintf(msg, args...) 79 return newError(Context(), ErrSyntaxError, xmsg) 80 } 81 82 func NewParseErrorNoCtx(msg string, args ...any) *Error { 83 xmsg := fmt.Sprintf(msg, args...) 84 return newError(Context(), ErrParseError, xmsg) 85 } 86 87 func NewConstraintViolationNoCtx(msg string, args ...any) *Error { 88 xmsg := fmt.Sprintf(msg, args...) 89 return newError(Context(), ErrConstraintViolation, xmsg) 90 } 91 92 func NewEmptyVectorNoCtx() *Error { 93 return newError(Context(), ErrEmptyVector) 94 } 95 96 func NewFileNotFoundNoCtx(f string) *Error { 97 return newError(Context(), ErrFileNotFound, f) 98 } 99 100 func NewFileAlreadyExistsNoCtx(f string) *Error { 101 return newError(Context(), ErrFileAlreadyExists, f) 102 } 103 104 func NewDBAlreadyExistsNoCtx(db string) *Error { 105 return newError(Context(), ErrDBAlreadyExists, db) 106 } 107 108 func NewTableAlreadyExistsNoCtx(t string) *Error { 109 return newError(Context(), ErrTableAlreadyExists, t) 110 } 111 112 func NewUnexpectedEOFNoCtx(f string) *Error { 113 return newError(Context(), ErrUnexpectedEOF, f) 114 } 115 116 func NewEmptyRangeNoCtx(f string) *Error { 117 return newError(Context(), ErrEmptyRange, f) 118 } 119 120 func NewSizeNotMatchNoCtx(f string) *Error { 121 return newError(Context(), ErrSizeNotMatch, f) 122 } 123 124 func NewInvalidPathNoCtx(f string) *Error { 125 return newError(Context(), ErrInvalidPath, f) 126 } 127 128 func NewInvalidStateNoCtx(msg string, args ...any) *Error { 129 xmsg := fmt.Sprintf(msg, args...) 130 return newError(Context(), ErrInvalidState, xmsg) 131 } 132 133 func NewInvalidServiceIndexNoCtx(idx int) *Error { 134 return newError(Context(), ErrInvalidServiceIndex, idx) 135 } 136 137 func NewBadDBNoCtx(name string) *Error { 138 return newError(Context(), ErrBadDB, name) 139 } 140 141 func NewNoDBNoCtx() *Error { 142 return newError(Context(), ErrNoDB) 143 } 144 145 func NewNoWorkingStoreNoCtx() *Error { 146 return newError(Context(), ErrNoWorkingStore) 147 } 148 149 func NewNoServiceNoCtx(name string) *Error { 150 return newError(Context(), ErrNoService, name) 151 } 152 153 func NewDupServiceNameNoCtx(name string) *Error { 154 return newError(Context(), ErrDupServiceName, name) 155 } 156 157 func NewWrongServiceNoCtx(exp, got string) *Error { 158 return newError(Context(), ErrWrongService, exp, got) 159 } 160 161 func NewNoSuchTableNoCtx(db, tbl string) *Error { 162 return newError(Context(), ErrNoSuchTable, db, tbl) 163 } 164 165 func NewClientClosedNoCtx() *Error { 166 return newError(Context(), ErrClientClosed) 167 } 168 169 func NewBackendClosedNoCtx() *Error { 170 return newError(Context(), ErrBackendClosed) 171 } 172 173 func NewStreamClosedNoCtx() *Error { 174 return newError(Context(), ErrStreamClosed) 175 } 176 177 func NewNoAvailableBackendNoCtx() *Error { 178 return newError(Context(), ErrNoAvailableBackend) 179 } 180 181 func NewTxnClosedNoCtx(txnID []byte) *Error { 182 id := "unknown" 183 if len(txnID) > 0 { 184 id = hex.EncodeToString(txnID) 185 } 186 return newError(Context(), ErrTxnClosed, id) 187 } 188 189 func NewTxnWriteConflictNoCtx(msg string, args ...any) *Error { 190 xmsg := fmt.Sprintf(msg, args...) 191 return newError(Context(), ErrTxnWriteConflict, xmsg) 192 } 193 194 func NewMissingTxnNoCtx() *Error { 195 return newError(Context(), ErrMissingTxn) 196 } 197 198 func NewTAEErrorNoCtx(msg string, args ...any) *Error { 199 xmsg := fmt.Sprintf(msg, args...) 200 return newError(Context(), ErrTAEError, xmsg) 201 } 202 203 func NewDNShardNotFoundNoCtx(uuid string, id uint64) *Error { 204 return newError(Context(), ErrDNShardNotFound, uuid, id) 205 } 206 207 func NewShardNotReportedNoCtx(uuid string, id uint64) *Error { 208 return newError(Context(), ErrShardNotReported, uuid, id) 209 } 210 211 func NewRpcErrorNoCtx(msg string) *Error { 212 return newError(Context(), ErrRpcError, msg) 213 } 214 215 func NewTxnNotFoundNoCtx() *Error { 216 return newError(Context(), ErrTxnNotFound) 217 } 218 219 func NewTxnNotActiveNoCtx(st string) *Error { 220 return newError(Context(), ErrTxnNotActive, st) 221 } 222 223 func NewTAECommitNoCtx(msg string, args ...any) *Error { 224 xmsg := fmt.Sprintf(msg, args...) 225 return newError(Context(), ErrTAECommit, xmsg) 226 } 227 228 func NewTAERollbackNoCtx(msg string, args ...any) *Error { 229 xmsg := fmt.Sprintf(msg, args...) 230 return newError(Context(), ErrTAERollback, xmsg) 231 } 232 233 func NewTAEPrepareNoCtx(msg string, args ...any) *Error { 234 xmsg := fmt.Sprintf(msg, args...) 235 return newError(Context(), ErrTAEPrepare, xmsg) 236 } 237 238 func NewTxnRWConflictNoCtx() *Error { 239 return newError(Context(), ErrTxnRWConflict) 240 } 241 242 func NewTxnWWConflictNoCtx() *Error { 243 return newError(Context(), ErrTxnWWConflict) 244 } 245 246 func NewNotFoundNoCtx() *Error { 247 return newError(Context(), ErrNotFound) 248 } 249 250 func NewDuplicateNoCtx() *Error { 251 return newError(Context(), ErrDuplicate) 252 } 253 254 func NewDuplicateEntryNoCtx(entry string, key string) *Error { 255 return newError(Context(), ErrDuplicateEntry, entry, key) 256 } 257 258 func NewRoleGrantedToSelfNoCtx(from, to string) *Error { 259 return newError(Context(), ErrRoleGrantedToSelf, from, to) 260 } 261 262 func NewTxnReadConflictNoCtx(msg string, args ...any) *Error { 263 xmsg := fmt.Sprintf(msg, args...) 264 return newError(Context(), ErrTxnReadConflict, xmsg) 265 } 266 267 func NewAppendableSegmentNotFoundNoCtx() *Error { 268 return newError(Context(), ErrAppendableSegmentNotFound) 269 } 270 271 func NewAppendableBlockNotFoundNoCtx() *Error { 272 return newError(Context(), ErrAppendableBlockNotFound) 273 } 274 275 func NewDeadLockDetectedNoCtx() *Error { 276 return newError(Context(), ErrDeadLockDetected) 277 } 278 279 func NewUDFAlreadyExistsNoCtx(f string) *Error { 280 return newError(Context(), ErrFunctionAlreadyExists, f) 281 } 282 283 func NewNoUDFNoCtx(f string) *Error { 284 return newError(Context(), ErrDropNonExistsFunction, f) 285 }