Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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