Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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