Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

error.go 57KB

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