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 62KB

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