You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.go 58KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package models
  6. import (
  7. "fmt"
  8. "code.gitea.io/gitea/modules/git"
  9. )
  10. // ErrNotExist represents a non-exist error.
  11. type ErrNotExist struct {
  12. ID int64
  13. }
  14. // IsErrNotExist checks if an error is an ErrNotExist
  15. func IsErrNotExist(err error) bool {
  16. _, ok := err.(ErrNotExist)
  17. return ok
  18. }
  19. func (err ErrNotExist) Error() string {
  20. return fmt.Sprintf("record does not exist [id: %d]", err.ID)
  21. }
  22. // ErrNameReserved represents a "reserved name" error.
  23. type ErrNameReserved struct {
  24. Name string
  25. }
  26. // IsErrNameReserved checks if an error is a ErrNameReserved.
  27. func IsErrNameReserved(err error) bool {
  28. _, ok := err.(ErrNameReserved)
  29. return ok
  30. }
  31. func (err ErrNameReserved) Error() string {
  32. return fmt.Sprintf("name is reserved [name: %s]", err.Name)
  33. }
  34. // ErrNamePatternNotAllowed represents a "pattern not allowed" error.
  35. type ErrNamePatternNotAllowed struct {
  36. Pattern string
  37. }
  38. // IsErrNamePatternNotAllowed checks if an error is an ErrNamePatternNotAllowed.
  39. func IsErrNamePatternNotAllowed(err error) bool {
  40. _, ok := err.(ErrNamePatternNotAllowed)
  41. return ok
  42. }
  43. func (err ErrNamePatternNotAllowed) Error() string {
  44. return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
  45. }
  46. // ErrNameCharsNotAllowed represents a "character not allowed in name" error.
  47. type ErrNameCharsNotAllowed struct {
  48. Name string
  49. }
  50. // IsErrNameCharsNotAllowed checks if an error is an ErrNameCharsNotAllowed.
  51. func IsErrNameCharsNotAllowed(err error) bool {
  52. _, ok := err.(ErrNameCharsNotAllowed)
  53. return ok
  54. }
  55. func (err ErrNameCharsNotAllowed) Error() string {
  56. return fmt.Sprintf("User name is invalid [%s]: must be valid alpha or numeric or dash(-_) or dot characters", err.Name)
  57. }
  58. // ErrSSHDisabled represents an "SSH disabled" error.
  59. type ErrSSHDisabled struct {
  60. }
  61. // IsErrSSHDisabled checks if an error is a ErrSSHDisabled.
  62. func IsErrSSHDisabled(err error) bool {
  63. _, ok := err.(ErrSSHDisabled)
  64. return ok
  65. }
  66. func (err ErrSSHDisabled) Error() string {
  67. return "SSH is disabled"
  68. }
  69. // ____ ___
  70. // | | \______ ___________
  71. // | | / ___// __ \_ __ \
  72. // | | /\___ \\ ___/| | \/
  73. // |______//____ >\___ >__|
  74. // \/ \/
  75. // ErrUserAlreadyExist represents a "user already exists" error.
  76. type ErrUserAlreadyExist struct {
  77. Name string
  78. }
  79. // IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.
  80. func IsErrUserAlreadyExist(err error) bool {
  81. _, ok := err.(ErrUserAlreadyExist)
  82. return ok
  83. }
  84. func (err ErrUserAlreadyExist) Error() string {
  85. return fmt.Sprintf("user already exists [name: %s]", err.Name)
  86. }
  87. // ErrUserNotExist represents a "UserNotExist" kind of error.
  88. type ErrUserNotExist struct {
  89. UID int64
  90. Name string
  91. KeyID int64
  92. }
  93. // IsErrUserNotExist checks if an error is a ErrUserNotExist.
  94. func IsErrUserNotExist(err error) bool {
  95. _, ok := err.(ErrUserNotExist)
  96. return ok
  97. }
  98. func (err ErrUserNotExist) Error() string {
  99. return fmt.Sprintf("user does not exist [uid: %d, name: %s, keyid: %d]", err.UID, err.Name, err.KeyID)
  100. }
  101. // ErrUserProhibitLogin represents a "ErrUserProhibitLogin" kind of error.
  102. type ErrUserProhibitLogin struct {
  103. UID int64
  104. Name string
  105. }
  106. // IsErrUserProhibitLogin checks if an error is a ErrUserProhibitLogin
  107. func IsErrUserProhibitLogin(err error) bool {
  108. _, ok := err.(ErrUserProhibitLogin)
  109. return ok
  110. }
  111. func (err ErrUserProhibitLogin) Error() string {
  112. return fmt.Sprintf("user is not allowed login [uid: %d, name: %s]", err.UID, err.Name)
  113. }
  114. // ErrUserInactive represents a "ErrUserInactive" kind of error.
  115. type ErrUserInactive struct {
  116. UID int64
  117. Name string
  118. }
  119. // IsErrUserInactive checks if an error is a ErrUserInactive
  120. func IsErrUserInactive(err error) bool {
  121. _, ok := err.(ErrUserInactive)
  122. return ok
  123. }
  124. func (err ErrUserInactive) Error() string {
  125. return fmt.Sprintf("user is inactive [uid: %d, name: %s]", err.UID, err.Name)
  126. }
  127. // ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.
  128. type ErrEmailAlreadyUsed struct {
  129. Email string
  130. }
  131. // IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
  132. func IsErrEmailAlreadyUsed(err error) bool {
  133. _, ok := err.(ErrEmailAlreadyUsed)
  134. return ok
  135. }
  136. func (err ErrEmailAlreadyUsed) Error() string {
  137. return fmt.Sprintf("e-mail already in use [email: %s]", err.Email)
  138. }
  139. // ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.
  140. type ErrOpenIDAlreadyUsed struct {
  141. OpenID string
  142. }
  143. // IsErrOpenIDAlreadyUsed checks if an error is a ErrOpenIDAlreadyUsed.
  144. func IsErrOpenIDAlreadyUsed(err error) bool {
  145. _, ok := err.(ErrOpenIDAlreadyUsed)
  146. return ok
  147. }
  148. func (err ErrOpenIDAlreadyUsed) Error() string {
  149. return fmt.Sprintf("OpenID already in use [oid: %s]", err.OpenID)
  150. }
  151. // ErrUserOwnRepos represents a "UserOwnRepos" kind of error.
  152. type ErrUserOwnRepos struct {
  153. UID int64
  154. }
  155. // IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.
  156. func IsErrUserOwnRepos(err error) bool {
  157. _, ok := err.(ErrUserOwnRepos)
  158. return ok
  159. }
  160. func (err ErrUserOwnRepos) Error() string {
  161. return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
  162. }
  163. // ErrUserHasOrgs represents a "UserHasOrgs" kind of error.
  164. type ErrUserHasOrgs struct {
  165. UID int64
  166. }
  167. // IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.
  168. func IsErrUserHasOrgs(err error) bool {
  169. _, ok := err.(ErrUserHasOrgs)
  170. return ok
  171. }
  172. func (err ErrUserHasOrgs) Error() string {
  173. return fmt.Sprintf("user still has membership of organizations [uid: %d]", err.UID)
  174. }
  175. // ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.
  176. type ErrUserNotAllowedCreateOrg struct {
  177. }
  178. // IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.
  179. func IsErrUserNotAllowedCreateOrg(err error) bool {
  180. _, ok := err.(ErrUserNotAllowedCreateOrg)
  181. return ok
  182. }
  183. func (err ErrUserNotAllowedCreateOrg) Error() string {
  184. return "user is not allowed to create organizations"
  185. }
  186. // ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.
  187. type ErrReachLimitOfRepo struct {
  188. Limit int
  189. }
  190. // IsErrReachLimitOfRepo checks if an error is a ErrReachLimitOfRepo.
  191. func IsErrReachLimitOfRepo(err error) bool {
  192. _, ok := err.(ErrReachLimitOfRepo)
  193. return ok
  194. }
  195. func (err ErrReachLimitOfRepo) Error() string {
  196. return fmt.Sprintf("user has reached maximum limit of repositories [limit: %d]", err.Limit)
  197. }
  198. // __ __.__ __ .__
  199. // / \ / \__| | _|__|
  200. // \ \/\/ / | |/ / |
  201. // \ /| | <| |
  202. // \__/\ / |__|__|_ \__|
  203. // \/ \/
  204. // ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.
  205. type ErrWikiAlreadyExist struct {
  206. Title string
  207. }
  208. // IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
  209. func IsErrWikiAlreadyExist(err error) bool {
  210. _, ok := err.(ErrWikiAlreadyExist)
  211. return ok
  212. }
  213. func (err ErrWikiAlreadyExist) Error() string {
  214. return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
  215. }
  216. // ErrWikiReservedName represents a reserved name error.
  217. type ErrWikiReservedName struct {
  218. Title string
  219. }
  220. // IsErrWikiReservedName checks if an error is an ErrWikiReservedName.
  221. func IsErrWikiReservedName(err error) bool {
  222. _, ok := err.(ErrWikiReservedName)
  223. return ok
  224. }
  225. func (err ErrWikiReservedName) Error() string {
  226. return fmt.Sprintf("wiki title is reserved: %s", err.Title)
  227. }
  228. // ErrWikiInvalidFileName represents an invalid wiki file name.
  229. type ErrWikiInvalidFileName struct {
  230. FileName string
  231. }
  232. // IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.
  233. func IsErrWikiInvalidFileName(err error) bool {
  234. _, ok := err.(ErrWikiInvalidFileName)
  235. return ok
  236. }
  237. func (err ErrWikiInvalidFileName) Error() string {
  238. return fmt.Sprintf("Invalid wiki filename: %s", err.FileName)
  239. }
  240. // __________ ___. .__ .__ ____ __.
  241. // \______ \__ _\_ |__ | | |__| ____ | |/ _|____ ___.__.
  242. // | ___/ | \ __ \| | | |/ ___\ | <_/ __ < | |
  243. // | | | | / \_\ \ |_| \ \___ | | \ ___/\___ |
  244. // |____| |____/|___ /____/__|\___ > |____|__ \___ > ____|
  245. // \/ \/ \/ \/\/
  246. // ErrKeyUnableVerify represents a "KeyUnableVerify" kind of error.
  247. type ErrKeyUnableVerify struct {
  248. Result string
  249. }
  250. // IsErrKeyUnableVerify checks if an error is a ErrKeyUnableVerify.
  251. func IsErrKeyUnableVerify(err error) bool {
  252. _, ok := err.(ErrKeyUnableVerify)
  253. return ok
  254. }
  255. func (err ErrKeyUnableVerify) Error() string {
  256. return fmt.Sprintf("Unable to verify key content [result: %s]", err.Result)
  257. }
  258. // ErrKeyNotExist represents a "KeyNotExist" kind of error.
  259. type ErrKeyNotExist struct {
  260. ID int64
  261. }
  262. // IsErrKeyNotExist checks if an error is a ErrKeyNotExist.
  263. func IsErrKeyNotExist(err error) bool {
  264. _, ok := err.(ErrKeyNotExist)
  265. return ok
  266. }
  267. func (err ErrKeyNotExist) Error() string {
  268. return fmt.Sprintf("public key does not exist [id: %d]", err.ID)
  269. }
  270. // ErrKeyAlreadyExist represents a "KeyAlreadyExist" kind of error.
  271. type ErrKeyAlreadyExist struct {
  272. OwnerID int64
  273. Fingerprint string
  274. Content string
  275. }
  276. // IsErrKeyAlreadyExist checks if an error is a ErrKeyAlreadyExist.
  277. func IsErrKeyAlreadyExist(err error) bool {
  278. _, ok := err.(ErrKeyAlreadyExist)
  279. return ok
  280. }
  281. func (err ErrKeyAlreadyExist) Error() string {
  282. return fmt.Sprintf("public key already exists [owner_id: %d, finger_print: %s, content: %s]",
  283. err.OwnerID, err.Fingerprint, err.Content)
  284. }
  285. // ErrKeyNameAlreadyUsed represents a "KeyNameAlreadyUsed" kind of error.
  286. type ErrKeyNameAlreadyUsed struct {
  287. OwnerID int64
  288. Name string
  289. }
  290. // IsErrKeyNameAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
  291. func IsErrKeyNameAlreadyUsed(err error) bool {
  292. _, ok := err.(ErrKeyNameAlreadyUsed)
  293. return ok
  294. }
  295. func (err ErrKeyNameAlreadyUsed) Error() string {
  296. return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
  297. }
  298. // ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
  299. type ErrGPGNoEmailFound struct {
  300. FailedEmails []string
  301. }
  302. // IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.
  303. func IsErrGPGNoEmailFound(err error) bool {
  304. _, ok := err.(ErrGPGNoEmailFound)
  305. return ok
  306. }
  307. func (err ErrGPGNoEmailFound) Error() string {
  308. return fmt.Sprintf("none of the emails attached to the GPG key could be found: %v", err.FailedEmails)
  309. }
  310. // ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.
  311. type ErrGPGKeyParsing struct {
  312. ParseError error
  313. }
  314. // IsErrGPGKeyParsing checks if an error is a ErrGPGKeyParsing.
  315. func IsErrGPGKeyParsing(err error) bool {
  316. _, ok := err.(ErrGPGKeyParsing)
  317. return ok
  318. }
  319. func (err ErrGPGKeyParsing) Error() string {
  320. return fmt.Sprintf("failed to parse gpg key %s", err.ParseError.Error())
  321. }
  322. // ErrGPGKeyNotExist represents a "GPGKeyNotExist" kind of error.
  323. type ErrGPGKeyNotExist struct {
  324. ID int64
  325. }
  326. // IsErrGPGKeyNotExist checks if an error is a ErrGPGKeyNotExist.
  327. func IsErrGPGKeyNotExist(err error) bool {
  328. _, ok := err.(ErrGPGKeyNotExist)
  329. return ok
  330. }
  331. func (err ErrGPGKeyNotExist) Error() string {
  332. return fmt.Sprintf("public gpg key does not exist [id: %d]", err.ID)
  333. }
  334. // ErrGPGKeyImportNotExist represents a "GPGKeyImportNotExist" kind of error.
  335. type ErrGPGKeyImportNotExist struct {
  336. ID string
  337. }
  338. // IsErrGPGKeyImportNotExist checks if an error is a ErrGPGKeyImportNotExist.
  339. func IsErrGPGKeyImportNotExist(err error) bool {
  340. _, ok := err.(ErrGPGKeyImportNotExist)
  341. return ok
  342. }
  343. func (err ErrGPGKeyImportNotExist) Error() string {
  344. return fmt.Sprintf("public gpg key import does not exist [id: %s]", err.ID)
  345. }
  346. // ErrGPGKeyIDAlreadyUsed represents a "GPGKeyIDAlreadyUsed" kind of error.
  347. type ErrGPGKeyIDAlreadyUsed struct {
  348. KeyID string
  349. }
  350. // IsErrGPGKeyIDAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
  351. func IsErrGPGKeyIDAlreadyUsed(err error) bool {
  352. _, ok := err.(ErrGPGKeyIDAlreadyUsed)
  353. return ok
  354. }
  355. func (err ErrGPGKeyIDAlreadyUsed) Error() string {
  356. return fmt.Sprintf("public key already exists [key_id: %s]", err.KeyID)
  357. }
  358. // ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error.
  359. type ErrGPGKeyAccessDenied struct {
  360. UserID int64
  361. KeyID int64
  362. }
  363. // IsErrGPGKeyAccessDenied checks if an error is a ErrGPGKeyAccessDenied.
  364. func IsErrGPGKeyAccessDenied(err error) bool {
  365. _, ok := err.(ErrGPGKeyAccessDenied)
  366. return ok
  367. }
  368. // Error pretty-prints an error of type ErrGPGKeyAccessDenied.
  369. func (err ErrGPGKeyAccessDenied) Error() string {
  370. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d]",
  371. err.UserID, err.KeyID)
  372. }
  373. // ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error.
  374. type ErrKeyAccessDenied struct {
  375. UserID int64
  376. KeyID int64
  377. Note string
  378. }
  379. // IsErrKeyAccessDenied checks if an error is a ErrKeyAccessDenied.
  380. func IsErrKeyAccessDenied(err error) bool {
  381. _, ok := err.(ErrKeyAccessDenied)
  382. return ok
  383. }
  384. func (err ErrKeyAccessDenied) Error() string {
  385. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d, note: %s]",
  386. err.UserID, err.KeyID, err.Note)
  387. }
  388. // ErrDeployKeyNotExist represents a "DeployKeyNotExist" kind of error.
  389. type ErrDeployKeyNotExist struct {
  390. ID int64
  391. KeyID int64
  392. RepoID int64
  393. }
  394. // IsErrDeployKeyNotExist checks if an error is a ErrDeployKeyNotExist.
  395. func IsErrDeployKeyNotExist(err error) bool {
  396. _, ok := err.(ErrDeployKeyNotExist)
  397. return ok
  398. }
  399. func (err ErrDeployKeyNotExist) Error() string {
  400. return fmt.Sprintf("Deploy key does not exist [id: %d, key_id: %d, repo_id: %d]", err.ID, err.KeyID, err.RepoID)
  401. }
  402. // ErrDeployKeyAlreadyExist represents a "DeployKeyAlreadyExist" kind of error.
  403. type ErrDeployKeyAlreadyExist struct {
  404. KeyID int64
  405. RepoID int64
  406. }
  407. // IsErrDeployKeyAlreadyExist checks if an error is a ErrDeployKeyAlreadyExist.
  408. func IsErrDeployKeyAlreadyExist(err error) bool {
  409. _, ok := err.(ErrDeployKeyAlreadyExist)
  410. return ok
  411. }
  412. func (err ErrDeployKeyAlreadyExist) Error() string {
  413. return fmt.Sprintf("public key already exists [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
  414. }
  415. // ErrDeployKeyNameAlreadyUsed represents a "DeployKeyNameAlreadyUsed" kind of error.
  416. type ErrDeployKeyNameAlreadyUsed struct {
  417. RepoID int64
  418. Name string
  419. }
  420. // IsErrDeployKeyNameAlreadyUsed checks if an error is a ErrDeployKeyNameAlreadyUsed.
  421. func IsErrDeployKeyNameAlreadyUsed(err error) bool {
  422. _, ok := err.(ErrDeployKeyNameAlreadyUsed)
  423. return ok
  424. }
  425. func (err ErrDeployKeyNameAlreadyUsed) Error() string {
  426. return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
  427. }
  428. // _____ ___________ __
  429. // / _ \ ____ ____ ____ ______ _____\__ ___/___ | | __ ____ ____
  430. // / /_\ \_/ ___\/ ___\/ __ \ / ___// ___/ | | / _ \| |/ // __ \ / \
  431. // / | \ \__\ \__\ ___/ \___ \ \___ \ | |( <_> ) <\ ___/| | \
  432. // \____|__ /\___ >___ >___ >____ >____ > |____| \____/|__|_ \\___ >___| /
  433. // \/ \/ \/ \/ \/ \/ \/ \/ \/
  434. // ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.
  435. type ErrAccessTokenNotExist struct {
  436. Token string
  437. }
  438. // IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.
  439. func IsErrAccessTokenNotExist(err error) bool {
  440. _, ok := err.(ErrAccessTokenNotExist)
  441. return ok
  442. }
  443. func (err ErrAccessTokenNotExist) Error() string {
  444. return fmt.Sprintf("access token does not exist [sha: %s]", err.Token)
  445. }
  446. // ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.
  447. type ErrAccessTokenEmpty struct {
  448. }
  449. // IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.
  450. func IsErrAccessTokenEmpty(err error) bool {
  451. _, ok := err.(ErrAccessTokenEmpty)
  452. return ok
  453. }
  454. func (err ErrAccessTokenEmpty) Error() string {
  455. return "access token is empty"
  456. }
  457. // ________ .__ __ .__
  458. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  459. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  460. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  461. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  462. // \/ /_____/ \/ \/ \/ \/ \/
  463. // ErrOrgNotExist represents a "OrgNotExist" kind of error.
  464. type ErrOrgNotExist struct {
  465. ID int64
  466. Name string
  467. }
  468. // IsErrOrgNotExist checks if an error is a ErrOrgNotExist.
  469. func IsErrOrgNotExist(err error) bool {
  470. _, ok := err.(ErrOrgNotExist)
  471. return ok
  472. }
  473. func (err ErrOrgNotExist) Error() string {
  474. return fmt.Sprintf("org does not exist [id: %d, name: %s]", err.ID, err.Name)
  475. }
  476. // ErrLastOrgOwner represents a "LastOrgOwner" kind of error.
  477. type ErrLastOrgOwner struct {
  478. UID int64
  479. }
  480. // IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.
  481. func IsErrLastOrgOwner(err error) bool {
  482. _, ok := err.(ErrLastOrgOwner)
  483. return ok
  484. }
  485. func (err ErrLastOrgOwner) Error() string {
  486. return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
  487. }
  488. //.____ ____________________
  489. //| | \_ _____/ _____/
  490. //| | | __) \_____ \
  491. //| |___| \ / \
  492. //|_______ \___ / /_______ /
  493. // \/ \/ \/
  494. // ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
  495. type ErrLFSLockNotExist struct {
  496. ID int64
  497. RepoID int64
  498. Path string
  499. }
  500. // IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.
  501. func IsErrLFSLockNotExist(err error) bool {
  502. _, ok := err.(ErrLFSLockNotExist)
  503. return ok
  504. }
  505. func (err ErrLFSLockNotExist) Error() string {
  506. return fmt.Sprintf("lfs lock does not exist [id: %d, rid: %d, path: %s]", err.ID, err.RepoID, err.Path)
  507. }
  508. // ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.
  509. type ErrLFSUnauthorizedAction struct {
  510. RepoID int64
  511. UserName string
  512. Mode AccessMode
  513. }
  514. // IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.
  515. func IsErrLFSUnauthorizedAction(err error) bool {
  516. _, ok := err.(ErrLFSUnauthorizedAction)
  517. return ok
  518. }
  519. func (err ErrLFSUnauthorizedAction) Error() string {
  520. if err.Mode == AccessModeWrite {
  521. return fmt.Sprintf("User %s doesn't have write access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  522. }
  523. return fmt.Sprintf("User %s doesn't have read access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  524. }
  525. // ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
  526. type ErrLFSLockAlreadyExist struct {
  527. RepoID int64
  528. Path string
  529. }
  530. // IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.
  531. func IsErrLFSLockAlreadyExist(err error) bool {
  532. _, ok := err.(ErrLFSLockAlreadyExist)
  533. return ok
  534. }
  535. func (err ErrLFSLockAlreadyExist) Error() string {
  536. return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
  537. }
  538. // ErrLFSFileLocked represents a "LFSFileLocked" kind of error.
  539. type ErrLFSFileLocked struct {
  540. RepoID int64
  541. Path string
  542. UserName string
  543. }
  544. // IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.
  545. func IsErrLFSFileLocked(err error) bool {
  546. _, ok := err.(ErrLFSFileLocked)
  547. return ok
  548. }
  549. func (err ErrLFSFileLocked) Error() string {
  550. return fmt.Sprintf("File is lfs locked [repo: %d, locked by: %s, path: %s]", err.RepoID, err.UserName, err.Path)
  551. }
  552. // __________ .__ __
  553. // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
  554. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
  555. // | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
  556. // |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
  557. // \/ \/|__| \/ \/
  558. // ErrRepoNotExist represents a "RepoNotExist" kind of error.
  559. type ErrRepoNotExist struct {
  560. ID int64
  561. UID int64
  562. OwnerName string
  563. Name string
  564. }
  565. // IsErrRepoNotExist checks if an error is a ErrRepoNotExist.
  566. func IsErrRepoNotExist(err error) bool {
  567. _, ok := err.(ErrRepoNotExist)
  568. return ok
  569. }
  570. func (err ErrRepoNotExist) Error() string {
  571. return fmt.Sprintf("repository does not exist [id: %d, uid: %d, owner_name: %s, name: %s]",
  572. err.ID, err.UID, err.OwnerName, err.Name)
  573. }
  574. // ErrRepoAlreadyExist represents a "RepoAlreadyExist" kind of error.
  575. type ErrRepoAlreadyExist struct {
  576. Uname string
  577. Name string
  578. }
  579. // IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.
  580. func IsErrRepoAlreadyExist(err error) bool {
  581. _, ok := err.(ErrRepoAlreadyExist)
  582. return ok
  583. }
  584. func (err ErrRepoAlreadyExist) Error() string {
  585. return fmt.Sprintf("repository already exists [uname: %s, name: %s]", err.Uname, err.Name)
  586. }
  587. // ErrForkAlreadyExist represents a "ForkAlreadyExist" kind of error.
  588. type ErrForkAlreadyExist struct {
  589. Uname string
  590. RepoName string
  591. ForkName string
  592. }
  593. // IsErrForkAlreadyExist checks if an error is an ErrForkAlreadyExist.
  594. func IsErrForkAlreadyExist(err error) bool {
  595. _, ok := err.(ErrForkAlreadyExist)
  596. return ok
  597. }
  598. func (err ErrForkAlreadyExist) Error() string {
  599. return fmt.Sprintf("repository is already forked by user [uname: %s, repo path: %s, fork path: %s]", err.Uname, err.RepoName, err.ForkName)
  600. }
  601. // ErrRepoRedirectNotExist represents a "RepoRedirectNotExist" kind of error.
  602. type ErrRepoRedirectNotExist struct {
  603. OwnerID int64
  604. RepoName string
  605. }
  606. // IsErrRepoRedirectNotExist check if an error is an ErrRepoRedirectNotExist.
  607. func IsErrRepoRedirectNotExist(err error) bool {
  608. _, ok := err.(ErrRepoRedirectNotExist)
  609. return ok
  610. }
  611. func (err ErrRepoRedirectNotExist) Error() string {
  612. return fmt.Sprintf("repository redirect does not exist [uid: %d, name: %s]", err.OwnerID, err.RepoName)
  613. }
  614. // ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.
  615. type ErrInvalidCloneAddr struct {
  616. IsURLError bool
  617. IsInvalidPath bool
  618. IsPermissionDenied bool
  619. }
  620. // IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
  621. func IsErrInvalidCloneAddr(err error) bool {
  622. _, ok := err.(ErrInvalidCloneAddr)
  623. return ok
  624. }
  625. func (err ErrInvalidCloneAddr) Error() string {
  626. return fmt.Sprintf("invalid clone address [is_url_error: %v, is_invalid_path: %v, is_permission_denied: %v]",
  627. err.IsURLError, err.IsInvalidPath, err.IsPermissionDenied)
  628. }
  629. // ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.
  630. type ErrUpdateTaskNotExist struct {
  631. UUID string
  632. }
  633. // IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.
  634. func IsErrUpdateTaskNotExist(err error) bool {
  635. _, ok := err.(ErrUpdateTaskNotExist)
  636. return ok
  637. }
  638. func (err ErrUpdateTaskNotExist) Error() string {
  639. return fmt.Sprintf("update task does not exist [uuid: %s]", err.UUID)
  640. }
  641. // ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.
  642. type ErrReleaseAlreadyExist struct {
  643. TagName string
  644. }
  645. // IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.
  646. func IsErrReleaseAlreadyExist(err error) bool {
  647. _, ok := err.(ErrReleaseAlreadyExist)
  648. return ok
  649. }
  650. func (err ErrReleaseAlreadyExist) Error() string {
  651. return fmt.Sprintf("release tag already exist [tag_name: %s]", err.TagName)
  652. }
  653. // ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.
  654. type ErrReleaseNotExist struct {
  655. ID int64
  656. TagName string
  657. }
  658. // IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.
  659. func IsErrReleaseNotExist(err error) bool {
  660. _, ok := err.(ErrReleaseNotExist)
  661. return ok
  662. }
  663. func (err ErrReleaseNotExist) Error() string {
  664. return fmt.Sprintf("release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
  665. }
  666. // ErrInvalidTagName represents a "InvalidTagName" kind of error.
  667. type ErrInvalidTagName struct {
  668. TagName string
  669. }
  670. // IsErrInvalidTagName checks if an error is a ErrInvalidTagName.
  671. func IsErrInvalidTagName(err error) bool {
  672. _, ok := err.(ErrInvalidTagName)
  673. return ok
  674. }
  675. func (err ErrInvalidTagName) Error() string {
  676. return fmt.Sprintf("release tag name is not valid [tag_name: %s]", err.TagName)
  677. }
  678. // ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.
  679. type ErrRepoFileAlreadyExists struct {
  680. Path string
  681. }
  682. // IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.
  683. func IsErrRepoFileAlreadyExists(err error) bool {
  684. _, ok := err.(ErrRepoFileAlreadyExists)
  685. return ok
  686. }
  687. func (err ErrRepoFileAlreadyExists) Error() string {
  688. return fmt.Sprintf("repository file already exists [path: %s]", err.Path)
  689. }
  690. // ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.
  691. type ErrRepoFileDoesNotExist struct {
  692. Path string
  693. Name string
  694. }
  695. // IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.
  696. func IsErrRepoFileDoesNotExist(err error) bool {
  697. _, ok := err.(ErrRepoFileDoesNotExist)
  698. return ok
  699. }
  700. func (err ErrRepoFileDoesNotExist) Error() string {
  701. return fmt.Sprintf("repository file does not exist [path: %s]", err.Path)
  702. }
  703. // ErrFilenameInvalid represents a "FilenameInvalid" kind of error.
  704. type ErrFilenameInvalid struct {
  705. Path string
  706. }
  707. // IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.
  708. func IsErrFilenameInvalid(err error) bool {
  709. _, ok := err.(ErrFilenameInvalid)
  710. return ok
  711. }
  712. func (err ErrFilenameInvalid) Error() string {
  713. return fmt.Sprintf("path contains a malformed path component [path: %s]", err.Path)
  714. }
  715. // ErrUserCannotCommit represents "UserCannotCommit" kind of error.
  716. type ErrUserCannotCommit struct {
  717. UserName string
  718. }
  719. // IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.
  720. func IsErrUserCannotCommit(err error) bool {
  721. _, ok := err.(ErrUserCannotCommit)
  722. return ok
  723. }
  724. func (err ErrUserCannotCommit) Error() string {
  725. return fmt.Sprintf("user cannot commit to repo [user: %s]", err.UserName)
  726. }
  727. // ErrFilePathInvalid represents a "FilePathInvalid" kind of error.
  728. type ErrFilePathInvalid struct {
  729. Message string
  730. Path string
  731. Name string
  732. Type git.EntryMode
  733. }
  734. // IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.
  735. func IsErrFilePathInvalid(err error) bool {
  736. _, ok := err.(ErrFilePathInvalid)
  737. return ok
  738. }
  739. func (err ErrFilePathInvalid) Error() string {
  740. if err.Message != "" {
  741. return err.Message
  742. }
  743. return fmt.Sprintf("path is invalid [path: %s]", err.Path)
  744. }
  745. // ErrFilePathProtected represents a "FilePathProtected" kind of error.
  746. type ErrFilePathProtected struct {
  747. Message string
  748. Path string
  749. }
  750. // IsErrFilePathProtected checks if an error is an ErrFilePathProtected.
  751. func IsErrFilePathProtected(err error) bool {
  752. _, ok := err.(ErrFilePathProtected)
  753. return ok
  754. }
  755. func (err ErrFilePathProtected) Error() string {
  756. if err.Message != "" {
  757. return err.Message
  758. }
  759. return fmt.Sprintf("path is protected and can not be changed [path: %s]", err.Path)
  760. }
  761. // ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo.
  762. type ErrUserDoesNotHaveAccessToRepo struct {
  763. UserID int64
  764. RepoName string
  765. }
  766. // IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExists.
  767. func IsErrUserDoesNotHaveAccessToRepo(err error) bool {
  768. _, ok := err.(ErrUserDoesNotHaveAccessToRepo)
  769. return ok
  770. }
  771. func (err ErrUserDoesNotHaveAccessToRepo) Error() string {
  772. return fmt.Sprintf("user doesn't have acces to repo [user_id: %d, repo_name: %s]", err.UserID, err.RepoName)
  773. }
  774. // ErrWontSign explains the first reason why a commit would not be signed
  775. // There may be other reasons - this is just the first reason found
  776. type ErrWontSign struct {
  777. Reason signingMode
  778. }
  779. func (e *ErrWontSign) Error() string {
  780. return fmt.Sprintf("wont sign: %s", e.Reason)
  781. }
  782. // IsErrWontSign checks if an error is a ErrWontSign
  783. func IsErrWontSign(err error) bool {
  784. _, ok := err.(*ErrWontSign)
  785. return ok
  786. }
  787. // __________ .__
  788. // \______ \____________ ____ ____ | |__
  789. // | | _/\_ __ \__ \ / \_/ ___\| | \
  790. // | | \ | | \// __ \| | \ \___| Y \
  791. // |______ / |__| (____ /___| /\___ >___| /
  792. // \/ \/ \/ \/ \/
  793. // ErrBranchAlreadyExists represents an error that branch with such name already exists.
  794. type ErrBranchAlreadyExists struct {
  795. BranchName string
  796. }
  797. // IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
  798. func IsErrBranchAlreadyExists(err error) bool {
  799. _, ok := err.(ErrBranchAlreadyExists)
  800. return ok
  801. }
  802. func (err ErrBranchAlreadyExists) Error() string {
  803. return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
  804. }
  805. // ErrBranchNameConflict represents an error that branch name conflicts with other branch.
  806. type ErrBranchNameConflict struct {
  807. BranchName string
  808. }
  809. // IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
  810. func IsErrBranchNameConflict(err error) bool {
  811. _, ok := err.(ErrBranchNameConflict)
  812. return ok
  813. }
  814. func (err ErrBranchNameConflict) Error() string {
  815. return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
  816. }
  817. // ErrBranchesEqual represents an error that branch name conflicts with other branch.
  818. type ErrBranchesEqual struct {
  819. BaseBranchName string
  820. HeadBranchName string
  821. }
  822. // IsErrBranchesEqual checks if an error is an ErrBranchesEqual.
  823. func IsErrBranchesEqual(err error) bool {
  824. _, ok := err.(ErrBranchesEqual)
  825. return ok
  826. }
  827. func (err ErrBranchesEqual) Error() string {
  828. return fmt.Sprintf("branches are equal [head: %sm base: %s]", err.HeadBranchName, err.BaseBranchName)
  829. }
  830. // ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
  831. type ErrNotAllowedToMerge struct {
  832. Reason string
  833. }
  834. // IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
  835. func IsErrNotAllowedToMerge(err error) bool {
  836. _, ok := err.(ErrNotAllowedToMerge)
  837. return ok
  838. }
  839. func (err ErrNotAllowedToMerge) Error() string {
  840. return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
  841. }
  842. // ErrTagAlreadyExists represents an error that tag with such name already exists.
  843. type ErrTagAlreadyExists struct {
  844. TagName string
  845. }
  846. // IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
  847. func IsErrTagAlreadyExists(err error) bool {
  848. _, ok := err.(ErrTagAlreadyExists)
  849. return ok
  850. }
  851. func (err ErrTagAlreadyExists) Error() string {
  852. return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
  853. }
  854. // ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.
  855. type ErrSHADoesNotMatch struct {
  856. Path string
  857. GivenSHA string
  858. CurrentSHA string
  859. }
  860. // IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.
  861. func IsErrSHADoesNotMatch(err error) bool {
  862. _, ok := err.(ErrSHADoesNotMatch)
  863. return ok
  864. }
  865. func (err ErrSHADoesNotMatch) Error() string {
  866. return fmt.Sprintf("sha does not match [given: %s, expected: %s]", err.GivenSHA, err.CurrentSHA)
  867. }
  868. // ErrSHANotFound represents a "SHADoesNotMatch" kind of error.
  869. type ErrSHANotFound struct {
  870. SHA string
  871. }
  872. // IsErrSHANotFound checks if an error is a ErrSHANotFound.
  873. func IsErrSHANotFound(err error) bool {
  874. _, ok := err.(ErrSHANotFound)
  875. return ok
  876. }
  877. func (err ErrSHANotFound) Error() string {
  878. return fmt.Sprintf("sha not found [%s]", err.SHA)
  879. }
  880. // ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.
  881. type ErrCommitIDDoesNotMatch struct {
  882. GivenCommitID string
  883. CurrentCommitID string
  884. }
  885. // IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.
  886. func IsErrCommitIDDoesNotMatch(err error) bool {
  887. _, ok := err.(ErrCommitIDDoesNotMatch)
  888. return ok
  889. }
  890. func (err ErrCommitIDDoesNotMatch) Error() string {
  891. return fmt.Sprintf("file CommitID does not match [given: %s, expected: %s]", err.GivenCommitID, err.CurrentCommitID)
  892. }
  893. // ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.
  894. type ErrSHAOrCommitIDNotProvided struct{}
  895. // IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.
  896. func IsErrSHAOrCommitIDNotProvided(err error) bool {
  897. _, ok := err.(ErrSHAOrCommitIDNotProvided)
  898. return ok
  899. }
  900. func (err ErrSHAOrCommitIDNotProvided) Error() string {
  901. return "a SHA or commmit ID must be proved when updating a file"
  902. }
  903. // __ __ ___. .__ __
  904. // / \ / \ ____\_ |__ | |__ ____ ____ | | __
  905. // \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /
  906. // \ /\ ___/| \_\ \ Y ( <_> | <_> ) <
  907. // \__/\ / \___ >___ /___| /\____/ \____/|__|_ \
  908. // \/ \/ \/ \/ \/
  909. // ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
  910. type ErrWebhookNotExist struct {
  911. ID int64
  912. }
  913. // IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
  914. func IsErrWebhookNotExist(err error) bool {
  915. _, ok := err.(ErrWebhookNotExist)
  916. return ok
  917. }
  918. func (err ErrWebhookNotExist) Error() string {
  919. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  920. }
  921. // .___
  922. // | | ______ ________ __ ____
  923. // | |/ ___// ___/ | \_/ __ \
  924. // | |\___ \ \___ \| | /\ ___/
  925. // |___/____ >____ >____/ \___ >
  926. // \/ \/ \/
  927. // ErrIssueNotExist represents a "IssueNotExist" kind of error.
  928. type ErrIssueNotExist struct {
  929. ID int64
  930. RepoID int64
  931. Index int64
  932. }
  933. // IsErrIssueNotExist checks if an error is a ErrIssueNotExist.
  934. func IsErrIssueNotExist(err error) bool {
  935. _, ok := err.(ErrIssueNotExist)
  936. return ok
  937. }
  938. func (err ErrIssueNotExist) Error() string {
  939. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  940. }
  941. // ErrIssueIsClosed represents a "IssueIsClosed" kind of error.
  942. type ErrIssueIsClosed struct {
  943. ID int64
  944. RepoID int64
  945. Index int64
  946. }
  947. // IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.
  948. func IsErrIssueIsClosed(err error) bool {
  949. _, ok := err.(ErrIssueIsClosed)
  950. return ok
  951. }
  952. func (err ErrIssueIsClosed) Error() string {
  953. return fmt.Sprintf("issue is closed [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  954. }
  955. // ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.
  956. type ErrIssueLabelTemplateLoad struct {
  957. TemplateFile string
  958. OriginalError error
  959. }
  960. // IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.
  961. func IsErrIssueLabelTemplateLoad(err error) bool {
  962. _, ok := err.(ErrIssueLabelTemplateLoad)
  963. return ok
  964. }
  965. func (err ErrIssueLabelTemplateLoad) Error() string {
  966. return fmt.Sprintf("Failed to load label template file '%s': %v", err.TemplateFile, err.OriginalError)
  967. }
  968. // ErrNewIssueInsert is used when the INSERT statement in newIssue fails
  969. type ErrNewIssueInsert struct {
  970. OriginalError error
  971. }
  972. // IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.
  973. func IsErrNewIssueInsert(err error) bool {
  974. _, ok := err.(ErrNewIssueInsert)
  975. return ok
  976. }
  977. func (err ErrNewIssueInsert) Error() string {
  978. return err.OriginalError.Error()
  979. }
  980. // ErrIssueWasClosed is used when close a closed issue
  981. type ErrIssueWasClosed struct {
  982. ID int64
  983. Index int64
  984. }
  985. // IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.
  986. func IsErrIssueWasClosed(err error) bool {
  987. _, ok := err.(ErrIssueWasClosed)
  988. return ok
  989. }
  990. func (err ErrIssueWasClosed) Error() string {
  991. return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index)
  992. }
  993. // ErrPullWasClosed is used close a closed pull request
  994. type ErrPullWasClosed struct {
  995. ID int64
  996. Index int64
  997. }
  998. // IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed.
  999. func IsErrPullWasClosed(err error) bool {
  1000. _, ok := err.(ErrPullWasClosed)
  1001. return ok
  1002. }
  1003. func (err ErrPullWasClosed) Error() string {
  1004. return fmt.Sprintf("Pull request [%d] %d was already closed", err.ID, err.Index)
  1005. }
  1006. // ErrForbiddenIssueReaction is used when a forbidden reaction was try to created
  1007. type ErrForbiddenIssueReaction struct {
  1008. Reaction string
  1009. }
  1010. // IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.
  1011. func IsErrForbiddenIssueReaction(err error) bool {
  1012. _, ok := err.(ErrForbiddenIssueReaction)
  1013. return ok
  1014. }
  1015. func (err ErrForbiddenIssueReaction) Error() string {
  1016. return fmt.Sprintf("'%s' is not an allowed reaction", err.Reaction)
  1017. }
  1018. // ErrReactionAlreadyExist is used when a existing reaction was try to created
  1019. type ErrReactionAlreadyExist struct {
  1020. Reaction string
  1021. }
  1022. // IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist.
  1023. func IsErrReactionAlreadyExist(err error) bool {
  1024. _, ok := err.(ErrReactionAlreadyExist)
  1025. return ok
  1026. }
  1027. func (err ErrReactionAlreadyExist) Error() string {
  1028. return fmt.Sprintf("reaction '%s' already exists", err.Reaction)
  1029. }
  1030. // __________ .__ .__ __________ __
  1031. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  1032. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  1033. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  1034. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  1035. // \/ \/ |__| \/ \/
  1036. // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
  1037. type ErrPullRequestNotExist struct {
  1038. ID int64
  1039. IssueID int64
  1040. HeadRepoID int64
  1041. BaseRepoID int64
  1042. HeadBranch string
  1043. BaseBranch string
  1044. }
  1045. // IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
  1046. func IsErrPullRequestNotExist(err error) bool {
  1047. _, ok := err.(ErrPullRequestNotExist)
  1048. return ok
  1049. }
  1050. func (err ErrPullRequestNotExist) Error() string {
  1051. return fmt.Sprintf("pull request does not exist [id: %d, issue_id: %d, head_repo_id: %d, base_repo_id: %d, head_branch: %s, base_branch: %s]",
  1052. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1053. }
  1054. // ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
  1055. type ErrPullRequestAlreadyExists struct {
  1056. ID int64
  1057. IssueID int64
  1058. HeadRepoID int64
  1059. BaseRepoID int64
  1060. HeadBranch string
  1061. BaseBranch string
  1062. }
  1063. // IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
  1064. func IsErrPullRequestAlreadyExists(err error) bool {
  1065. _, ok := err.(ErrPullRequestAlreadyExists)
  1066. return ok
  1067. }
  1068. // Error does pretty-printing :D
  1069. func (err ErrPullRequestAlreadyExists) Error() string {
  1070. return fmt.Sprintf("pull request already exists for these targets [id: %d, issue_id: %d, head_repo_id: %d, base_repo_id: %d, head_branch: %s, base_branch: %s]",
  1071. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1072. }
  1073. // ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error
  1074. type ErrPullRequestHeadRepoMissing struct {
  1075. ID int64
  1076. HeadRepoID int64
  1077. }
  1078. // IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.
  1079. func IsErrErrPullRequestHeadRepoMissing(err error) bool {
  1080. _, ok := err.(ErrPullRequestHeadRepoMissing)
  1081. return ok
  1082. }
  1083. // Error does pretty-printing :D
  1084. func (err ErrPullRequestHeadRepoMissing) Error() string {
  1085. return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]",
  1086. err.ID, err.HeadRepoID)
  1087. }
  1088. // ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
  1089. type ErrInvalidMergeStyle struct {
  1090. ID int64
  1091. Style MergeStyle
  1092. }
  1093. // IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.
  1094. func IsErrInvalidMergeStyle(err error) bool {
  1095. _, ok := err.(ErrInvalidMergeStyle)
  1096. return ok
  1097. }
  1098. func (err ErrInvalidMergeStyle) Error() string {
  1099. return fmt.Sprintf("merge strategy is not allowed or is invalid [repo_id: %d, strategy: %s]",
  1100. err.ID, err.Style)
  1101. }
  1102. // ErrMergeConflicts represents an error if merging fails with a conflict
  1103. type ErrMergeConflicts struct {
  1104. Style MergeStyle
  1105. StdOut string
  1106. StdErr string
  1107. Err error
  1108. }
  1109. // IsErrMergeConflicts checks if an error is a ErrMergeConflicts.
  1110. func IsErrMergeConflicts(err error) bool {
  1111. _, ok := err.(ErrMergeConflicts)
  1112. return ok
  1113. }
  1114. func (err ErrMergeConflicts) Error() string {
  1115. return fmt.Sprintf("Merge Conflict Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1116. }
  1117. // ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories
  1118. type ErrMergeUnrelatedHistories struct {
  1119. Style MergeStyle
  1120. StdOut string
  1121. StdErr string
  1122. Err error
  1123. }
  1124. // IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.
  1125. func IsErrMergeUnrelatedHistories(err error) bool {
  1126. _, ok := err.(ErrMergeUnrelatedHistories)
  1127. return ok
  1128. }
  1129. func (err ErrMergeUnrelatedHistories) Error() string {
  1130. return fmt.Sprintf("Merge UnrelatedHistories Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1131. }
  1132. // ErrRebaseConflicts represents an error if rebase fails with a conflict
  1133. type ErrRebaseConflicts struct {
  1134. Style MergeStyle
  1135. CommitSHA string
  1136. StdOut string
  1137. StdErr string
  1138. Err error
  1139. }
  1140. // IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.
  1141. func IsErrRebaseConflicts(err error) bool {
  1142. _, ok := err.(ErrRebaseConflicts)
  1143. return ok
  1144. }
  1145. func (err ErrRebaseConflicts) Error() string {
  1146. return fmt.Sprintf("Rebase Error: %v: Whilst Rebasing: %s\n%s\n%s", err.Err, err.CommitSHA, err.StdErr, err.StdOut)
  1147. }
  1148. // ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error
  1149. type ErrPullRequestHasMerged struct {
  1150. ID int64
  1151. IssueID int64
  1152. HeadRepoID int64
  1153. BaseRepoID int64
  1154. HeadBranch string
  1155. BaseBranch string
  1156. }
  1157. // IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.
  1158. func IsErrPullRequestHasMerged(err error) bool {
  1159. _, ok := err.(ErrPullRequestHasMerged)
  1160. return ok
  1161. }
  1162. // Error does pretty-printing :D
  1163. func (err ErrPullRequestHasMerged) Error() string {
  1164. return fmt.Sprintf("pull request has merged [id: %d, issue_id: %d, head_repo_id: %d, base_repo_id: %d, head_branch: %s, base_branch: %s]",
  1165. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1166. }
  1167. // _________ __
  1168. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  1169. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  1170. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  1171. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  1172. // \/ \/ \/ \/ \/
  1173. // ErrCommentNotExist represents a "CommentNotExist" kind of error.
  1174. type ErrCommentNotExist struct {
  1175. ID int64
  1176. IssueID int64
  1177. }
  1178. // IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
  1179. func IsErrCommentNotExist(err error) bool {
  1180. _, ok := err.(ErrCommentNotExist)
  1181. return ok
  1182. }
  1183. func (err ErrCommentNotExist) Error() string {
  1184. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  1185. }
  1186. // _________ __ __ .__
  1187. // / _____// |_ ____ ________ _ _______ _/ |_ ____ | |__
  1188. // \_____ \\ __\/ _ \\____ \ \/ \/ /\__ \\ __\/ ___\| | \
  1189. // / \| | ( <_> ) |_> > / / __ \| | \ \___| Y \
  1190. // /_______ /|__| \____/| __/ \/\_/ (____ /__| \___ >___| /
  1191. // \/ |__| \/ \/ \/
  1192. // ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.
  1193. type ErrStopwatchNotExist struct {
  1194. ID int64
  1195. }
  1196. // IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.
  1197. func IsErrStopwatchNotExist(err error) bool {
  1198. _, ok := err.(ErrStopwatchNotExist)
  1199. return ok
  1200. }
  1201. func (err ErrStopwatchNotExist) Error() string {
  1202. return fmt.Sprintf("stopwatch does not exist [id: %d]", err.ID)
  1203. }
  1204. // ___________ __ .______________.__
  1205. // \__ ___/___________ ____ | | __ ____ __| _/\__ ___/|__| _____ ____
  1206. // | | \_ __ \__ \ _/ ___\| |/ // __ \ / __ | | | | |/ \_/ __ \
  1207. // | | | | \// __ \\ \___| <\ ___// /_/ | | | | | Y Y \ ___/
  1208. // |____| |__| (____ /\___ >__|_ \\___ >____ | |____| |__|__|_| /\___ >
  1209. // \/ \/ \/ \/ \/ \/ \/
  1210. // ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.
  1211. type ErrTrackedTimeNotExist struct {
  1212. ID int64
  1213. }
  1214. // IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.
  1215. func IsErrTrackedTimeNotExist(err error) bool {
  1216. _, ok := err.(ErrTrackedTimeNotExist)
  1217. return ok
  1218. }
  1219. func (err ErrTrackedTimeNotExist) Error() string {
  1220. return fmt.Sprintf("tracked time does not exist [id: %d]", err.ID)
  1221. }
  1222. // .____ ___. .__
  1223. // | | _____ \_ |__ ____ | |
  1224. // | | \__ \ | __ \_/ __ \| |
  1225. // | |___ / __ \| \_\ \ ___/| |__
  1226. // |_______ (____ /___ /\___ >____/
  1227. // \/ \/ \/ \/
  1228. // ErrRepoLabelNotExist represents a "RepoLabelNotExist" kind of error.
  1229. type ErrRepoLabelNotExist struct {
  1230. LabelID int64
  1231. RepoID int64
  1232. }
  1233. // IsErrRepoLabelNotExist checks if an error is a RepoErrLabelNotExist.
  1234. func IsErrRepoLabelNotExist(err error) bool {
  1235. _, ok := err.(ErrRepoLabelNotExist)
  1236. return ok
  1237. }
  1238. func (err ErrRepoLabelNotExist) Error() string {
  1239. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  1240. }
  1241. // ErrOrgLabelNotExist represents a "OrgLabelNotExist" kind of error.
  1242. type ErrOrgLabelNotExist struct {
  1243. LabelID int64
  1244. OrgID int64
  1245. }
  1246. // IsErrOrgLabelNotExist checks if an error is a OrgErrLabelNotExist.
  1247. func IsErrOrgLabelNotExist(err error) bool {
  1248. _, ok := err.(ErrOrgLabelNotExist)
  1249. return ok
  1250. }
  1251. func (err ErrOrgLabelNotExist) Error() string {
  1252. return fmt.Sprintf("label does not exist [label_id: %d, org_id: %d]", err.LabelID, err.OrgID)
  1253. }
  1254. // ErrLabelNotExist represents a "LabelNotExist" kind of error.
  1255. type ErrLabelNotExist struct {
  1256. LabelID int64
  1257. }
  1258. // IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
  1259. func IsErrLabelNotExist(err error) bool {
  1260. _, ok := err.(ErrLabelNotExist)
  1261. return ok
  1262. }
  1263. func (err ErrLabelNotExist) Error() string {
  1264. return fmt.Sprintf("label does not exist [label_id: %d]", err.LabelID)
  1265. }
  1266. // _____ .__.__ __
  1267. // / \ |__| | ____ _______/ |_ ____ ____ ____
  1268. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  1269. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  1270. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  1271. // \/ \/ \/ \/ \/
  1272. // ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.
  1273. type ErrMilestoneNotExist struct {
  1274. ID int64
  1275. RepoID int64
  1276. }
  1277. // IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
  1278. func IsErrMilestoneNotExist(err error) bool {
  1279. _, ok := err.(ErrMilestoneNotExist)
  1280. return ok
  1281. }
  1282. func (err ErrMilestoneNotExist) Error() string {
  1283. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  1284. }
  1285. // _____ __ __ .__ __
  1286. // / _ \_/ |__/ |______ ____ | |__ _____ ____ _____/ |_
  1287. // / /_\ \ __\ __\__ \ _/ ___\| | \ / \_/ __ \ / \ __\
  1288. // / | \ | | | / __ \\ \___| Y \ Y Y \ ___/| | \ |
  1289. // \____|__ /__| |__| (____ /\___ >___| /__|_| /\___ >___| /__|
  1290. // \/ \/ \/ \/ \/ \/ \/
  1291. // ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.
  1292. type ErrAttachmentNotExist struct {
  1293. ID int64
  1294. UUID string
  1295. }
  1296. // IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.
  1297. func IsErrAttachmentNotExist(err error) bool {
  1298. _, ok := err.(ErrAttachmentNotExist)
  1299. return ok
  1300. }
  1301. func (err ErrAttachmentNotExist) Error() string {
  1302. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1303. }
  1304. // .____ .__ _________
  1305. // | | ____ ____ |__| ____ / _____/ ____ __ _________ ____ ____
  1306. // | | / _ \ / ___\| |/ \ \_____ \ / _ \| | \_ __ \_/ ___\/ __ \
  1307. // | |__( <_> ) /_/ > | | \ / ( <_> ) | /| | \/\ \__\ ___/
  1308. // |_______ \____/\___ /|__|___| / /_______ /\____/|____/ |__| \___ >___ >
  1309. // \/ /_____/ \/ \/ \/ \/
  1310. // ErrLoginSourceNotExist represents a "LoginSourceNotExist" kind of error.
  1311. type ErrLoginSourceNotExist struct {
  1312. ID int64
  1313. }
  1314. // IsErrLoginSourceNotExist checks if an error is a ErrLoginSourceNotExist.
  1315. func IsErrLoginSourceNotExist(err error) bool {
  1316. _, ok := err.(ErrLoginSourceNotExist)
  1317. return ok
  1318. }
  1319. func (err ErrLoginSourceNotExist) Error() string {
  1320. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  1321. }
  1322. // ErrLoginSourceAlreadyExist represents a "LoginSourceAlreadyExist" kind of error.
  1323. type ErrLoginSourceAlreadyExist struct {
  1324. Name string
  1325. }
  1326. // IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.
  1327. func IsErrLoginSourceAlreadyExist(err error) bool {
  1328. _, ok := err.(ErrLoginSourceAlreadyExist)
  1329. return ok
  1330. }
  1331. func (err ErrLoginSourceAlreadyExist) Error() string {
  1332. return fmt.Sprintf("login source already exists [name: %s]", err.Name)
  1333. }
  1334. // ErrLoginSourceInUse represents a "LoginSourceInUse" kind of error.
  1335. type ErrLoginSourceInUse struct {
  1336. ID int64
  1337. }
  1338. // IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.
  1339. func IsErrLoginSourceInUse(err error) bool {
  1340. _, ok := err.(ErrLoginSourceInUse)
  1341. return ok
  1342. }
  1343. func (err ErrLoginSourceInUse) Error() string {
  1344. return fmt.Sprintf("login source is still used by some users [id: %d]", err.ID)
  1345. }
  1346. // ___________
  1347. // \__ ___/___ _____ _____
  1348. // | |_/ __ \\__ \ / \
  1349. // | |\ ___/ / __ \| Y Y \
  1350. // |____| \___ >____ /__|_| /
  1351. // \/ \/ \/
  1352. // ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
  1353. type ErrTeamAlreadyExist struct {
  1354. OrgID int64
  1355. Name string
  1356. }
  1357. // IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
  1358. func IsErrTeamAlreadyExist(err error) bool {
  1359. _, ok := err.(ErrTeamAlreadyExist)
  1360. return ok
  1361. }
  1362. func (err ErrTeamAlreadyExist) Error() string {
  1363. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  1364. }
  1365. // ErrTeamNotExist represents a "TeamNotExist" error
  1366. type ErrTeamNotExist struct {
  1367. OrgID int64
  1368. TeamID int64
  1369. Name string
  1370. }
  1371. // IsErrTeamNotExist checks if an error is a ErrTeamNotExist.
  1372. func IsErrTeamNotExist(err error) bool {
  1373. _, ok := err.(ErrTeamNotExist)
  1374. return ok
  1375. }
  1376. func (err ErrTeamNotExist) Error() string {
  1377. return fmt.Sprintf("team does not exist [org_id %d, team_id %d, name: %s]", err.OrgID, err.TeamID, err.Name)
  1378. }
  1379. //
  1380. // Two-factor authentication
  1381. //
  1382. // ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication.
  1383. type ErrTwoFactorNotEnrolled struct {
  1384. UID int64
  1385. }
  1386. // IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled.
  1387. func IsErrTwoFactorNotEnrolled(err error) bool {
  1388. _, ok := err.(ErrTwoFactorNotEnrolled)
  1389. return ok
  1390. }
  1391. func (err ErrTwoFactorNotEnrolled) Error() string {
  1392. return fmt.Sprintf("user not enrolled in 2FA [uid: %d]", err.UID)
  1393. }
  1394. // ____ ___ .__ .___
  1395. // | | \______ | | _________ __| _/
  1396. // | | /\____ \| | / _ \__ \ / __ |
  1397. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  1398. // |______/ | __/|____/\____(____ /\____ |
  1399. // |__| \/ \/
  1400. //
  1401. // ErrUploadNotExist represents a "UploadNotExist" kind of error.
  1402. type ErrUploadNotExist struct {
  1403. ID int64
  1404. UUID string
  1405. }
  1406. // IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
  1407. func IsErrUploadNotExist(err error) bool {
  1408. _, ok := err.(ErrAttachmentNotExist)
  1409. return ok
  1410. }
  1411. func (err ErrUploadNotExist) Error() string {
  1412. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1413. }
  1414. // ___________ __ .__ .____ .__ ____ ___
  1415. // \_ _____/__ ____/ |_ ___________ ____ _____ | | | | ____ ____ |__| ____ | | \______ ___________
  1416. // | __)_\ \/ /\ __\/ __ \_ __ \/ \\__ \ | | | | / _ \ / ___\| |/ \ | | / ___// __ \_ __ \
  1417. // | \> < | | \ ___/| | \/ | \/ __ \| |__ | |__( <_> ) /_/ > | | \ | | /\___ \\ ___/| | \/
  1418. // /_______ /__/\_ \ |__| \___ >__| |___| (____ /____/ |_______ \____/\___ /|__|___| / |______//____ >\___ >__|
  1419. // \/ \/ \/ \/ \/ \/ /_____/ \/ \/ \/
  1420. // ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
  1421. type ErrExternalLoginUserAlreadyExist struct {
  1422. ExternalID string
  1423. UserID int64
  1424. LoginSourceID int64
  1425. }
  1426. // IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.
  1427. func IsErrExternalLoginUserAlreadyExist(err error) bool {
  1428. _, ok := err.(ErrExternalLoginUserAlreadyExist)
  1429. return ok
  1430. }
  1431. func (err ErrExternalLoginUserAlreadyExist) Error() string {
  1432. return fmt.Sprintf("external login user already exists [externalID: %s, userID: %d, loginSourceID: %d]", err.ExternalID, err.UserID, err.LoginSourceID)
  1433. }
  1434. // ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
  1435. type ErrExternalLoginUserNotExist struct {
  1436. UserID int64
  1437. LoginSourceID int64
  1438. }
  1439. // IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.
  1440. func IsErrExternalLoginUserNotExist(err error) bool {
  1441. _, ok := err.(ErrExternalLoginUserNotExist)
  1442. return ok
  1443. }
  1444. func (err ErrExternalLoginUserNotExist) Error() string {
  1445. return fmt.Sprintf("external login user link does not exists [userID: %d, loginSourceID: %d]", err.UserID, err.LoginSourceID)
  1446. }
  1447. // ____ ________________________________ .__ __ __ .__
  1448. // | | \_____ \_ _____/\______ \ ____ ____ |__| _______/ |_____________ _/ |_|__| ____ ____
  1449. // | | // ____/| __) | _// __ \ / ___\| |/ ___/\ __\_ __ \__ \\ __\ |/ _ \ / \
  1450. // | | // \| \ | | \ ___// /_/ > |\___ \ | | | | \// __ \| | | ( <_> ) | \
  1451. // |______/ \_______ \___ / |____|_ /\___ >___ /|__/____ > |__| |__| (____ /__| |__|\____/|___| /
  1452. // \/ \/ \/ \/_____/ \/ \/ \/
  1453. // ErrU2FRegistrationNotExist represents a "ErrU2FRegistrationNotExist" kind of error.
  1454. type ErrU2FRegistrationNotExist struct {
  1455. ID int64
  1456. }
  1457. func (err ErrU2FRegistrationNotExist) Error() string {
  1458. return fmt.Sprintf("U2F registration does not exist [id: %d]", err.ID)
  1459. }
  1460. // IsErrU2FRegistrationNotExist checks if an error is a ErrU2FRegistrationNotExist.
  1461. func IsErrU2FRegistrationNotExist(err error) bool {
  1462. _, ok := err.(ErrU2FRegistrationNotExist)
  1463. return ok
  1464. }
  1465. // .___ ________ .___ .__
  1466. // | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
  1467. // | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
  1468. // | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
  1469. // |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
  1470. // \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
  1471. // ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
  1472. type ErrDependencyExists struct {
  1473. IssueID int64
  1474. DependencyID int64
  1475. }
  1476. // IsErrDependencyExists checks if an error is a ErrDependencyExists.
  1477. func IsErrDependencyExists(err error) bool {
  1478. _, ok := err.(ErrDependencyExists)
  1479. return ok
  1480. }
  1481. func (err ErrDependencyExists) Error() string {
  1482. return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1483. }
  1484. // ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
  1485. type ErrDependencyNotExists struct {
  1486. IssueID int64
  1487. DependencyID int64
  1488. }
  1489. // IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
  1490. func IsErrDependencyNotExists(err error) bool {
  1491. _, ok := err.(ErrDependencyNotExists)
  1492. return ok
  1493. }
  1494. func (err ErrDependencyNotExists) Error() string {
  1495. return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1496. }
  1497. // ErrCircularDependency represents a "DependencyCircular" kind of error.
  1498. type ErrCircularDependency struct {
  1499. IssueID int64
  1500. DependencyID int64
  1501. }
  1502. // IsErrCircularDependency checks if an error is a ErrCircularDependency.
  1503. func IsErrCircularDependency(err error) bool {
  1504. _, ok := err.(ErrCircularDependency)
  1505. return ok
  1506. }
  1507. func (err ErrCircularDependency) Error() string {
  1508. return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1509. }
  1510. // ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
  1511. type ErrDependenciesLeft struct {
  1512. IssueID int64
  1513. }
  1514. // IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
  1515. func IsErrDependenciesLeft(err error) bool {
  1516. _, ok := err.(ErrDependenciesLeft)
  1517. return ok
  1518. }
  1519. func (err ErrDependenciesLeft) Error() string {
  1520. return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
  1521. }
  1522. // ErrUnknownDependencyType represents an error where an unknown dependency type was passed
  1523. type ErrUnknownDependencyType struct {
  1524. Type DependencyType
  1525. }
  1526. // IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
  1527. func IsErrUnknownDependencyType(err error) bool {
  1528. _, ok := err.(ErrUnknownDependencyType)
  1529. return ok
  1530. }
  1531. func (err ErrUnknownDependencyType) Error() string {
  1532. return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
  1533. }
  1534. // __________ .__
  1535. // \______ \ _______ _|__| ______ _ __
  1536. // | _// __ \ \/ / |/ __ \ \/ \/ /
  1537. // | | \ ___/\ /| \ ___/\ /
  1538. // |____|_ /\___ >\_/ |__|\___ >\/\_/
  1539. // \/ \/ \/
  1540. // ErrReviewNotExist represents a "ReviewNotExist" kind of error.
  1541. type ErrReviewNotExist struct {
  1542. ID int64
  1543. }
  1544. // IsErrReviewNotExist checks if an error is a ErrReviewNotExist.
  1545. func IsErrReviewNotExist(err error) bool {
  1546. _, ok := err.(ErrReviewNotExist)
  1547. return ok
  1548. }
  1549. func (err ErrReviewNotExist) Error() string {
  1550. return fmt.Sprintf("review does not exist [id: %d]", err.ID)
  1551. }
  1552. // ________ _____ __ .__
  1553. // \_____ \ / _ \ __ ___/ |_| |__
  1554. // / | \ / /_\ \| | \ __\ | \
  1555. // / | \/ | \ | /| | | Y \
  1556. // \_______ /\____|__ /____/ |__| |___| /
  1557. // \/ \/ \/
  1558. // ErrOAuthClientIDInvalid will be thrown if client id cannot be found
  1559. type ErrOAuthClientIDInvalid struct {
  1560. ClientID string
  1561. }
  1562. // IsErrOauthClientIDInvalid checks if an error is a ErrReviewNotExist.
  1563. func IsErrOauthClientIDInvalid(err error) bool {
  1564. _, ok := err.(ErrOAuthClientIDInvalid)
  1565. return ok
  1566. }
  1567. // Error returns the error message
  1568. func (err ErrOAuthClientIDInvalid) Error() string {
  1569. return fmt.Sprintf("Client ID invalid [Client ID: %s]", err.ClientID)
  1570. }
  1571. // ErrOAuthApplicationNotFound will be thrown if id cannot be found
  1572. type ErrOAuthApplicationNotFound struct {
  1573. ID int64
  1574. }
  1575. // IsErrOAuthApplicationNotFound checks if an error is a ErrReviewNotExist.
  1576. func IsErrOAuthApplicationNotFound(err error) bool {
  1577. _, ok := err.(ErrOAuthApplicationNotFound)
  1578. return ok
  1579. }
  1580. // Error returns the error message
  1581. func (err ErrOAuthApplicationNotFound) Error() string {
  1582. return fmt.Sprintf("OAuth application not found [ID: %d]", err.ID)
  1583. }