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

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