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

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