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

error.go 58KB

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