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

error.go 53KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759
  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. // ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
  777. type ErrNotAllowedToMerge struct {
  778. Reason string
  779. }
  780. // IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
  781. func IsErrNotAllowedToMerge(err error) bool {
  782. _, ok := err.(ErrNotAllowedToMerge)
  783. return ok
  784. }
  785. func (err ErrNotAllowedToMerge) Error() string {
  786. return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
  787. }
  788. // ErrTagAlreadyExists represents an error that tag with such name already exists.
  789. type ErrTagAlreadyExists struct {
  790. TagName string
  791. }
  792. // IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
  793. func IsErrTagAlreadyExists(err error) bool {
  794. _, ok := err.(ErrTagAlreadyExists)
  795. return ok
  796. }
  797. func (err ErrTagAlreadyExists) Error() string {
  798. return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
  799. }
  800. // ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.
  801. type ErrSHADoesNotMatch struct {
  802. Path string
  803. GivenSHA string
  804. CurrentSHA string
  805. }
  806. // IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.
  807. func IsErrSHADoesNotMatch(err error) bool {
  808. _, ok := err.(ErrSHADoesNotMatch)
  809. return ok
  810. }
  811. func (err ErrSHADoesNotMatch) Error() string {
  812. return fmt.Sprintf("sha does not match [given: %s, expected: %s]", err.GivenSHA, err.CurrentSHA)
  813. }
  814. // ErrSHANotFound represents a "SHADoesNotMatch" kind of error.
  815. type ErrSHANotFound struct {
  816. SHA string
  817. }
  818. // IsErrSHANotFound checks if an error is a ErrSHANotFound.
  819. func IsErrSHANotFound(err error) bool {
  820. _, ok := err.(ErrSHANotFound)
  821. return ok
  822. }
  823. func (err ErrSHANotFound) Error() string {
  824. return fmt.Sprintf("sha not found [%s]", err.SHA)
  825. }
  826. // ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.
  827. type ErrCommitIDDoesNotMatch struct {
  828. GivenCommitID string
  829. CurrentCommitID string
  830. }
  831. // IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.
  832. func IsErrCommitIDDoesNotMatch(err error) bool {
  833. _, ok := err.(ErrCommitIDDoesNotMatch)
  834. return ok
  835. }
  836. func (err ErrCommitIDDoesNotMatch) Error() string {
  837. return fmt.Sprintf("file CommitID does not match [given: %s, expected: %s]", err.GivenCommitID, err.CurrentCommitID)
  838. }
  839. // ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.
  840. type ErrSHAOrCommitIDNotProvided struct{}
  841. // IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.
  842. func IsErrSHAOrCommitIDNotProvided(err error) bool {
  843. _, ok := err.(ErrSHAOrCommitIDNotProvided)
  844. return ok
  845. }
  846. func (err ErrSHAOrCommitIDNotProvided) Error() string {
  847. return fmt.Sprintf("a SHA or commmit ID must be proved when updating a file")
  848. }
  849. // __ __ ___. .__ __
  850. // / \ / \ ____\_ |__ | |__ ____ ____ | | __
  851. // \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /
  852. // \ /\ ___/| \_\ \ Y ( <_> | <_> ) <
  853. // \__/\ / \___ >___ /___| /\____/ \____/|__|_ \
  854. // \/ \/ \/ \/ \/
  855. // ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
  856. type ErrWebhookNotExist struct {
  857. ID int64
  858. }
  859. // IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
  860. func IsErrWebhookNotExist(err error) bool {
  861. _, ok := err.(ErrWebhookNotExist)
  862. return ok
  863. }
  864. func (err ErrWebhookNotExist) Error() string {
  865. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  866. }
  867. // .___
  868. // | | ______ ________ __ ____
  869. // | |/ ___// ___/ | \_/ __ \
  870. // | |\___ \ \___ \| | /\ ___/
  871. // |___/____ >____ >____/ \___ >
  872. // \/ \/ \/
  873. // ErrIssueNotExist represents a "IssueNotExist" kind of error.
  874. type ErrIssueNotExist struct {
  875. ID int64
  876. RepoID int64
  877. Index int64
  878. }
  879. // IsErrIssueNotExist checks if an error is a ErrIssueNotExist.
  880. func IsErrIssueNotExist(err error) bool {
  881. _, ok := err.(ErrIssueNotExist)
  882. return ok
  883. }
  884. func (err ErrIssueNotExist) Error() string {
  885. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  886. }
  887. // ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.
  888. type ErrIssueLabelTemplateLoad struct {
  889. TemplateFile string
  890. OriginalError error
  891. }
  892. // IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.
  893. func IsErrIssueLabelTemplateLoad(err error) bool {
  894. _, ok := err.(ErrIssueLabelTemplateLoad)
  895. return ok
  896. }
  897. func (err ErrIssueLabelTemplateLoad) Error() string {
  898. return fmt.Sprintf("Failed to load label template file '%s': %v", err.TemplateFile, err.OriginalError)
  899. }
  900. // ErrNewIssueInsert is used when the INSERT statement in newIssue fails
  901. type ErrNewIssueInsert struct {
  902. OriginalError error
  903. }
  904. // IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.
  905. func IsErrNewIssueInsert(err error) bool {
  906. _, ok := err.(ErrNewIssueInsert)
  907. return ok
  908. }
  909. func (err ErrNewIssueInsert) Error() string {
  910. return err.OriginalError.Error()
  911. }
  912. // __________ .__ .__ __________ __
  913. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  914. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  915. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  916. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  917. // \/ \/ |__| \/ \/
  918. // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
  919. type ErrPullRequestNotExist struct {
  920. ID int64
  921. IssueID int64
  922. HeadRepoID int64
  923. BaseRepoID int64
  924. HeadBranch string
  925. BaseBranch string
  926. }
  927. // IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
  928. func IsErrPullRequestNotExist(err error) bool {
  929. _, ok := err.(ErrPullRequestNotExist)
  930. return ok
  931. }
  932. func (err ErrPullRequestNotExist) Error() string {
  933. 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]",
  934. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  935. }
  936. // ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
  937. type ErrPullRequestAlreadyExists struct {
  938. ID int64
  939. IssueID int64
  940. HeadRepoID int64
  941. BaseRepoID int64
  942. HeadBranch string
  943. BaseBranch string
  944. }
  945. // IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
  946. func IsErrPullRequestAlreadyExists(err error) bool {
  947. _, ok := err.(ErrPullRequestAlreadyExists)
  948. return ok
  949. }
  950. // Error does pretty-printing :D
  951. func (err ErrPullRequestAlreadyExists) Error() string {
  952. 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]",
  953. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  954. }
  955. // ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error
  956. type ErrPullRequestHeadRepoMissing struct {
  957. ID int64
  958. HeadRepoID int64
  959. }
  960. // IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.
  961. func IsErrErrPullRequestHeadRepoMissing(err error) bool {
  962. _, ok := err.(ErrPullRequestHeadRepoMissing)
  963. return ok
  964. }
  965. // Error does pretty-printing :D
  966. func (err ErrPullRequestHeadRepoMissing) Error() string {
  967. return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]",
  968. err.ID, err.HeadRepoID)
  969. }
  970. // ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
  971. type ErrInvalidMergeStyle struct {
  972. ID int64
  973. Style MergeStyle
  974. }
  975. // IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.
  976. func IsErrInvalidMergeStyle(err error) bool {
  977. _, ok := err.(ErrInvalidMergeStyle)
  978. return ok
  979. }
  980. func (err ErrInvalidMergeStyle) Error() string {
  981. return fmt.Sprintf("merge strategy is not allowed or is invalid [repo_id: %d, strategy: %s]",
  982. err.ID, err.Style)
  983. }
  984. // ErrMergeConflicts represents an error if merging fails with a conflict
  985. type ErrMergeConflicts struct {
  986. Style MergeStyle
  987. StdOut string
  988. StdErr string
  989. Err error
  990. }
  991. // IsErrMergeConflicts checks if an error is a ErrMergeConflicts.
  992. func IsErrMergeConflicts(err error) bool {
  993. _, ok := err.(ErrMergeConflicts)
  994. return ok
  995. }
  996. func (err ErrMergeConflicts) Error() string {
  997. return fmt.Sprintf("Merge Conflict Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  998. }
  999. // ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories
  1000. type ErrMergeUnrelatedHistories struct {
  1001. Style MergeStyle
  1002. StdOut string
  1003. StdErr string
  1004. Err error
  1005. }
  1006. // IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.
  1007. func IsErrMergeUnrelatedHistories(err error) bool {
  1008. _, ok := err.(ErrMergeUnrelatedHistories)
  1009. return ok
  1010. }
  1011. func (err ErrMergeUnrelatedHistories) Error() string {
  1012. return fmt.Sprintf("Merge UnrelatedHistories Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1013. }
  1014. // ErrMergePushOutOfDate represents an error if merging fails due to unrelated histories
  1015. type ErrMergePushOutOfDate struct {
  1016. Style MergeStyle
  1017. StdOut string
  1018. StdErr string
  1019. Err error
  1020. }
  1021. // IsErrMergePushOutOfDate checks if an error is a ErrMergePushOutOfDate.
  1022. func IsErrMergePushOutOfDate(err error) bool {
  1023. _, ok := err.(ErrMergePushOutOfDate)
  1024. return ok
  1025. }
  1026. func (err ErrMergePushOutOfDate) Error() string {
  1027. return fmt.Sprintf("Merge PushOutOfDate Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1028. }
  1029. // ErrRebaseConflicts represents an error if rebase fails with a conflict
  1030. type ErrRebaseConflicts struct {
  1031. Style MergeStyle
  1032. CommitSHA string
  1033. StdOut string
  1034. StdErr string
  1035. Err error
  1036. }
  1037. // IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.
  1038. func IsErrRebaseConflicts(err error) bool {
  1039. _, ok := err.(ErrRebaseConflicts)
  1040. return ok
  1041. }
  1042. func (err ErrRebaseConflicts) Error() string {
  1043. return fmt.Sprintf("Rebase Error: %v: Whilst Rebasing: %s\n%s\n%s", err.Err, err.CommitSHA, err.StdErr, err.StdOut)
  1044. }
  1045. // _________ __
  1046. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  1047. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  1048. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  1049. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  1050. // \/ \/ \/ \/ \/
  1051. // ErrCommentNotExist represents a "CommentNotExist" kind of error.
  1052. type ErrCommentNotExist struct {
  1053. ID int64
  1054. IssueID int64
  1055. }
  1056. // IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
  1057. func IsErrCommentNotExist(err error) bool {
  1058. _, ok := err.(ErrCommentNotExist)
  1059. return ok
  1060. }
  1061. func (err ErrCommentNotExist) Error() string {
  1062. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  1063. }
  1064. // _________ __ __ .__
  1065. // / _____// |_ ____ ________ _ _______ _/ |_ ____ | |__
  1066. // \_____ \\ __\/ _ \\____ \ \/ \/ /\__ \\ __\/ ___\| | \
  1067. // / \| | ( <_> ) |_> > / / __ \| | \ \___| Y \
  1068. // /_______ /|__| \____/| __/ \/\_/ (____ /__| \___ >___| /
  1069. // \/ |__| \/ \/ \/
  1070. // ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.
  1071. type ErrStopwatchNotExist struct {
  1072. ID int64
  1073. }
  1074. // IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.
  1075. func IsErrStopwatchNotExist(err error) bool {
  1076. _, ok := err.(ErrStopwatchNotExist)
  1077. return ok
  1078. }
  1079. func (err ErrStopwatchNotExist) Error() string {
  1080. return fmt.Sprintf("stopwatch does not exist [id: %d]", err.ID)
  1081. }
  1082. // ___________ __ .______________.__
  1083. // \__ ___/___________ ____ | | __ ____ __| _/\__ ___/|__| _____ ____
  1084. // | | \_ __ \__ \ _/ ___\| |/ // __ \ / __ | | | | |/ \_/ __ \
  1085. // | | | | \// __ \\ \___| <\ ___// /_/ | | | | | Y Y \ ___/
  1086. // |____| |__| (____ /\___ >__|_ \\___ >____ | |____| |__|__|_| /\___ >
  1087. // \/ \/ \/ \/ \/ \/ \/
  1088. // ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.
  1089. type ErrTrackedTimeNotExist struct {
  1090. ID int64
  1091. }
  1092. // IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.
  1093. func IsErrTrackedTimeNotExist(err error) bool {
  1094. _, ok := err.(ErrTrackedTimeNotExist)
  1095. return ok
  1096. }
  1097. func (err ErrTrackedTimeNotExist) Error() string {
  1098. return fmt.Sprintf("tracked time does not exist [id: %d]", err.ID)
  1099. }
  1100. // .____ ___. .__
  1101. // | | _____ \_ |__ ____ | |
  1102. // | | \__ \ | __ \_/ __ \| |
  1103. // | |___ / __ \| \_\ \ ___/| |__
  1104. // |_______ (____ /___ /\___ >____/
  1105. // \/ \/ \/ \/
  1106. // ErrLabelNotExist represents a "LabelNotExist" kind of error.
  1107. type ErrLabelNotExist struct {
  1108. LabelID int64
  1109. RepoID int64
  1110. }
  1111. // IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
  1112. func IsErrLabelNotExist(err error) bool {
  1113. _, ok := err.(ErrLabelNotExist)
  1114. return ok
  1115. }
  1116. func (err ErrLabelNotExist) Error() string {
  1117. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  1118. }
  1119. // _____ .__.__ __
  1120. // / \ |__| | ____ _______/ |_ ____ ____ ____
  1121. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  1122. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  1123. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  1124. // \/ \/ \/ \/ \/
  1125. // ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.
  1126. type ErrMilestoneNotExist struct {
  1127. ID int64
  1128. RepoID int64
  1129. }
  1130. // IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
  1131. func IsErrMilestoneNotExist(err error) bool {
  1132. _, ok := err.(ErrMilestoneNotExist)
  1133. return ok
  1134. }
  1135. func (err ErrMilestoneNotExist) Error() string {
  1136. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  1137. }
  1138. // _____ __ __ .__ __
  1139. // / _ \_/ |__/ |______ ____ | |__ _____ ____ _____/ |_
  1140. // / /_\ \ __\ __\__ \ _/ ___\| | \ / \_/ __ \ / \ __\
  1141. // / | \ | | | / __ \\ \___| Y \ Y Y \ ___/| | \ |
  1142. // \____|__ /__| |__| (____ /\___ >___| /__|_| /\___ >___| /__|
  1143. // \/ \/ \/ \/ \/ \/ \/
  1144. // ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.
  1145. type ErrAttachmentNotExist struct {
  1146. ID int64
  1147. UUID string
  1148. }
  1149. // IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.
  1150. func IsErrAttachmentNotExist(err error) bool {
  1151. _, ok := err.(ErrAttachmentNotExist)
  1152. return ok
  1153. }
  1154. func (err ErrAttachmentNotExist) Error() string {
  1155. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1156. }
  1157. // .____ .__ _________
  1158. // | | ____ ____ |__| ____ / _____/ ____ __ _________ ____ ____
  1159. // | | / _ \ / ___\| |/ \ \_____ \ / _ \| | \_ __ \_/ ___\/ __ \
  1160. // | |__( <_> ) /_/ > | | \ / ( <_> ) | /| | \/\ \__\ ___/
  1161. // |_______ \____/\___ /|__|___| / /_______ /\____/|____/ |__| \___ >___ >
  1162. // \/ /_____/ \/ \/ \/ \/
  1163. // ErrLoginSourceNotExist represents a "LoginSourceNotExist" kind of error.
  1164. type ErrLoginSourceNotExist struct {
  1165. ID int64
  1166. }
  1167. // IsErrLoginSourceNotExist checks if an error is a ErrLoginSourceNotExist.
  1168. func IsErrLoginSourceNotExist(err error) bool {
  1169. _, ok := err.(ErrLoginSourceNotExist)
  1170. return ok
  1171. }
  1172. func (err ErrLoginSourceNotExist) Error() string {
  1173. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  1174. }
  1175. // ErrLoginSourceAlreadyExist represents a "LoginSourceAlreadyExist" kind of error.
  1176. type ErrLoginSourceAlreadyExist struct {
  1177. Name string
  1178. }
  1179. // IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.
  1180. func IsErrLoginSourceAlreadyExist(err error) bool {
  1181. _, ok := err.(ErrLoginSourceAlreadyExist)
  1182. return ok
  1183. }
  1184. func (err ErrLoginSourceAlreadyExist) Error() string {
  1185. return fmt.Sprintf("login source already exists [name: %s]", err.Name)
  1186. }
  1187. // ErrLoginSourceInUse represents a "LoginSourceInUse" kind of error.
  1188. type ErrLoginSourceInUse struct {
  1189. ID int64
  1190. }
  1191. // IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.
  1192. func IsErrLoginSourceInUse(err error) bool {
  1193. _, ok := err.(ErrLoginSourceInUse)
  1194. return ok
  1195. }
  1196. func (err ErrLoginSourceInUse) Error() string {
  1197. return fmt.Sprintf("login source is still used by some users [id: %d]", err.ID)
  1198. }
  1199. // ___________
  1200. // \__ ___/___ _____ _____
  1201. // | |_/ __ \\__ \ / \
  1202. // | |\ ___/ / __ \| Y Y \
  1203. // |____| \___ >____ /__|_| /
  1204. // \/ \/ \/
  1205. // ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
  1206. type ErrTeamAlreadyExist struct {
  1207. OrgID int64
  1208. Name string
  1209. }
  1210. // IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
  1211. func IsErrTeamAlreadyExist(err error) bool {
  1212. _, ok := err.(ErrTeamAlreadyExist)
  1213. return ok
  1214. }
  1215. func (err ErrTeamAlreadyExist) Error() string {
  1216. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  1217. }
  1218. // ErrTeamNotExist represents a "TeamNotExist" error
  1219. type ErrTeamNotExist struct {
  1220. OrgID int64
  1221. TeamID int64
  1222. Name string
  1223. }
  1224. // IsErrTeamNotExist checks if an error is a ErrTeamNotExist.
  1225. func IsErrTeamNotExist(err error) bool {
  1226. _, ok := err.(ErrTeamNotExist)
  1227. return ok
  1228. }
  1229. func (err ErrTeamNotExist) Error() string {
  1230. return fmt.Sprintf("team does not exist [org_id %d, team_id %d, name: %s]", err.OrgID, err.TeamID, err.Name)
  1231. }
  1232. //
  1233. // Two-factor authentication
  1234. //
  1235. // ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication.
  1236. type ErrTwoFactorNotEnrolled struct {
  1237. UID int64
  1238. }
  1239. // IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled.
  1240. func IsErrTwoFactorNotEnrolled(err error) bool {
  1241. _, ok := err.(ErrTwoFactorNotEnrolled)
  1242. return ok
  1243. }
  1244. func (err ErrTwoFactorNotEnrolled) Error() string {
  1245. return fmt.Sprintf("user not enrolled in 2FA [uid: %d]", err.UID)
  1246. }
  1247. // ____ ___ .__ .___
  1248. // | | \______ | | _________ __| _/
  1249. // | | /\____ \| | / _ \__ \ / __ |
  1250. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  1251. // |______/ | __/|____/\____(____ /\____ |
  1252. // |__| \/ \/
  1253. //
  1254. // ErrUploadNotExist represents a "UploadNotExist" kind of error.
  1255. type ErrUploadNotExist struct {
  1256. ID int64
  1257. UUID string
  1258. }
  1259. // IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
  1260. func IsErrUploadNotExist(err error) bool {
  1261. _, ok := err.(ErrAttachmentNotExist)
  1262. return ok
  1263. }
  1264. func (err ErrUploadNotExist) Error() string {
  1265. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1266. }
  1267. // ___________ __ .__ .____ .__ ____ ___
  1268. // \_ _____/__ ____/ |_ ___________ ____ _____ | | | | ____ ____ |__| ____ | | \______ ___________
  1269. // | __)_\ \/ /\ __\/ __ \_ __ \/ \\__ \ | | | | / _ \ / ___\| |/ \ | | / ___// __ \_ __ \
  1270. // | \> < | | \ ___/| | \/ | \/ __ \| |__ | |__( <_> ) /_/ > | | \ | | /\___ \\ ___/| | \/
  1271. // /_______ /__/\_ \ |__| \___ >__| |___| (____ /____/ |_______ \____/\___ /|__|___| / |______//____ >\___ >__|
  1272. // \/ \/ \/ \/ \/ \/ /_____/ \/ \/ \/
  1273. // ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
  1274. type ErrExternalLoginUserAlreadyExist struct {
  1275. ExternalID string
  1276. UserID int64
  1277. LoginSourceID int64
  1278. }
  1279. // IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.
  1280. func IsErrExternalLoginUserAlreadyExist(err error) bool {
  1281. _, ok := err.(ErrExternalLoginUserAlreadyExist)
  1282. return ok
  1283. }
  1284. func (err ErrExternalLoginUserAlreadyExist) Error() string {
  1285. return fmt.Sprintf("external login user already exists [externalID: %s, userID: %d, loginSourceID: %d]", err.ExternalID, err.UserID, err.LoginSourceID)
  1286. }
  1287. // ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
  1288. type ErrExternalLoginUserNotExist struct {
  1289. UserID int64
  1290. LoginSourceID int64
  1291. }
  1292. // IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.
  1293. func IsErrExternalLoginUserNotExist(err error) bool {
  1294. _, ok := err.(ErrExternalLoginUserNotExist)
  1295. return ok
  1296. }
  1297. func (err ErrExternalLoginUserNotExist) Error() string {
  1298. return fmt.Sprintf("external login user link does not exists [userID: %d, loginSourceID: %d]", err.UserID, err.LoginSourceID)
  1299. }
  1300. // ____ ________________________________ .__ __ __ .__
  1301. // | | \_____ \_ _____/\______ \ ____ ____ |__| _______/ |_____________ _/ |_|__| ____ ____
  1302. // | | // ____/| __) | _// __ \ / ___\| |/ ___/\ __\_ __ \__ \\ __\ |/ _ \ / \
  1303. // | | // \| \ | | \ ___// /_/ > |\___ \ | | | | \// __ \| | | ( <_> ) | \
  1304. // |______/ \_______ \___ / |____|_ /\___ >___ /|__/____ > |__| |__| (____ /__| |__|\____/|___| /
  1305. // \/ \/ \/ \/_____/ \/ \/ \/
  1306. // ErrU2FRegistrationNotExist represents a "ErrU2FRegistrationNotExist" kind of error.
  1307. type ErrU2FRegistrationNotExist struct {
  1308. ID int64
  1309. }
  1310. func (err ErrU2FRegistrationNotExist) Error() string {
  1311. return fmt.Sprintf("U2F registration does not exist [id: %d]", err.ID)
  1312. }
  1313. // IsErrU2FRegistrationNotExist checks if an error is a ErrU2FRegistrationNotExist.
  1314. func IsErrU2FRegistrationNotExist(err error) bool {
  1315. _, ok := err.(ErrU2FRegistrationNotExist)
  1316. return ok
  1317. }
  1318. // .___ ________ .___ .__
  1319. // | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
  1320. // | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
  1321. // | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
  1322. // |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
  1323. // \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
  1324. // ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
  1325. type ErrDependencyExists struct {
  1326. IssueID int64
  1327. DependencyID int64
  1328. }
  1329. // IsErrDependencyExists checks if an error is a ErrDependencyExists.
  1330. func IsErrDependencyExists(err error) bool {
  1331. _, ok := err.(ErrDependencyExists)
  1332. return ok
  1333. }
  1334. func (err ErrDependencyExists) Error() string {
  1335. return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1336. }
  1337. // ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
  1338. type ErrDependencyNotExists struct {
  1339. IssueID int64
  1340. DependencyID int64
  1341. }
  1342. // IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
  1343. func IsErrDependencyNotExists(err error) bool {
  1344. _, ok := err.(ErrDependencyNotExists)
  1345. return ok
  1346. }
  1347. func (err ErrDependencyNotExists) Error() string {
  1348. return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1349. }
  1350. // ErrCircularDependency represents a "DependencyCircular" kind of error.
  1351. type ErrCircularDependency struct {
  1352. IssueID int64
  1353. DependencyID int64
  1354. }
  1355. // IsErrCircularDependency checks if an error is a ErrCircularDependency.
  1356. func IsErrCircularDependency(err error) bool {
  1357. _, ok := err.(ErrCircularDependency)
  1358. return ok
  1359. }
  1360. func (err ErrCircularDependency) Error() string {
  1361. return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1362. }
  1363. // ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
  1364. type ErrDependenciesLeft struct {
  1365. IssueID int64
  1366. }
  1367. // IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
  1368. func IsErrDependenciesLeft(err error) bool {
  1369. _, ok := err.(ErrDependenciesLeft)
  1370. return ok
  1371. }
  1372. func (err ErrDependenciesLeft) Error() string {
  1373. return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
  1374. }
  1375. // ErrUnknownDependencyType represents an error where an unknown dependency type was passed
  1376. type ErrUnknownDependencyType struct {
  1377. Type DependencyType
  1378. }
  1379. // IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
  1380. func IsErrUnknownDependencyType(err error) bool {
  1381. _, ok := err.(ErrUnknownDependencyType)
  1382. return ok
  1383. }
  1384. func (err ErrUnknownDependencyType) Error() string {
  1385. return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
  1386. }
  1387. // __________ .__
  1388. // \______ \ _______ _|__| ______ _ __
  1389. // | _// __ \ \/ / |/ __ \ \/ \/ /
  1390. // | | \ ___/\ /| \ ___/\ /
  1391. // |____|_ /\___ >\_/ |__|\___ >\/\_/
  1392. // \/ \/ \/
  1393. // ErrReviewNotExist represents a "ReviewNotExist" kind of error.
  1394. type ErrReviewNotExist struct {
  1395. ID int64
  1396. }
  1397. // IsErrReviewNotExist checks if an error is a ErrReviewNotExist.
  1398. func IsErrReviewNotExist(err error) bool {
  1399. _, ok := err.(ErrReviewNotExist)
  1400. return ok
  1401. }
  1402. func (err ErrReviewNotExist) Error() string {
  1403. return fmt.Sprintf("review does not exist [id: %d]", err.ID)
  1404. }
  1405. // ________ _____ __ .__
  1406. // \_____ \ / _ \ __ ___/ |_| |__
  1407. // / | \ / /_\ \| | \ __\ | \
  1408. // / | \/ | \ | /| | | Y \
  1409. // \_______ /\____|__ /____/ |__| |___| /
  1410. // \/ \/ \/
  1411. // ErrOAuthClientIDInvalid will be thrown if client id cannot be found
  1412. type ErrOAuthClientIDInvalid struct {
  1413. ClientID string
  1414. }
  1415. // IsErrOauthClientIDInvalid checks if an error is a ErrReviewNotExist.
  1416. func IsErrOauthClientIDInvalid(err error) bool {
  1417. _, ok := err.(ErrOAuthClientIDInvalid)
  1418. return ok
  1419. }
  1420. // Error returns the error message
  1421. func (err ErrOAuthClientIDInvalid) Error() string {
  1422. return fmt.Sprintf("Client ID invalid [Client ID: %s]", err.ClientID)
  1423. }
  1424. // ErrOAuthApplicationNotFound will be thrown if id cannot be found
  1425. type ErrOAuthApplicationNotFound struct {
  1426. ID int64
  1427. }
  1428. // IsErrOAuthApplicationNotFound checks if an error is a ErrReviewNotExist.
  1429. func IsErrOAuthApplicationNotFound(err error) bool {
  1430. _, ok := err.(ErrOAuthApplicationNotFound)
  1431. return ok
  1432. }
  1433. // Error returns the error message
  1434. func (err ErrOAuthApplicationNotFound) Error() string {
  1435. return fmt.Sprintf("OAuth application not found [ID: %d]", err.ID)
  1436. }