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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571
  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. // ErrNameReserved represents a "reserved name" error.
  11. type ErrNameReserved struct {
  12. Name string
  13. }
  14. // IsErrNameReserved checks if an error is a ErrNameReserved.
  15. func IsErrNameReserved(err error) bool {
  16. _, ok := err.(ErrNameReserved)
  17. return ok
  18. }
  19. func (err ErrNameReserved) Error() string {
  20. return fmt.Sprintf("name is reserved [name: %s]", err.Name)
  21. }
  22. // ErrNamePatternNotAllowed represents a "pattern not allowed" error.
  23. type ErrNamePatternNotAllowed struct {
  24. Pattern string
  25. }
  26. // IsErrNamePatternNotAllowed checks if an error is an ErrNamePatternNotAllowed.
  27. func IsErrNamePatternNotAllowed(err error) bool {
  28. _, ok := err.(ErrNamePatternNotAllowed)
  29. return ok
  30. }
  31. func (err ErrNamePatternNotAllowed) Error() string {
  32. return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
  33. }
  34. // ErrSSHDisabled represents an "SSH disabled" error.
  35. type ErrSSHDisabled struct {
  36. }
  37. // IsErrSSHDisabled checks if an error is a ErrSSHDisabled.
  38. func IsErrSSHDisabled(err error) bool {
  39. _, ok := err.(ErrSSHDisabled)
  40. return ok
  41. }
  42. func (err ErrSSHDisabled) Error() string {
  43. return "SSH is disabled"
  44. }
  45. // ____ ___
  46. // | | \______ ___________
  47. // | | / ___// __ \_ __ \
  48. // | | /\___ \\ ___/| | \/
  49. // |______//____ >\___ >__|
  50. // \/ \/
  51. // ErrUserAlreadyExist represents a "user already exists" error.
  52. type ErrUserAlreadyExist struct {
  53. Name string
  54. }
  55. // IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.
  56. func IsErrUserAlreadyExist(err error) bool {
  57. _, ok := err.(ErrUserAlreadyExist)
  58. return ok
  59. }
  60. func (err ErrUserAlreadyExist) Error() string {
  61. return fmt.Sprintf("user already exists [name: %s]", err.Name)
  62. }
  63. // ErrUserNotExist represents a "UserNotExist" kind of error.
  64. type ErrUserNotExist struct {
  65. UID int64
  66. Name string
  67. KeyID int64
  68. }
  69. // IsErrUserNotExist checks if an error is a ErrUserNotExist.
  70. func IsErrUserNotExist(err error) bool {
  71. _, ok := err.(ErrUserNotExist)
  72. return ok
  73. }
  74. func (err ErrUserNotExist) Error() string {
  75. return fmt.Sprintf("user does not exist [uid: %d, name: %s, keyid: %d]", err.UID, err.Name, err.KeyID)
  76. }
  77. // ErrUserProhibitLogin represents a "ErrUserProhibitLogin" kind of error.
  78. type ErrUserProhibitLogin struct {
  79. UID int64
  80. Name string
  81. }
  82. // IsErrUserProhibitLogin checks if an error is a ErrUserProhibitLogin
  83. func IsErrUserProhibitLogin(err error) bool {
  84. _, ok := err.(ErrUserProhibitLogin)
  85. return ok
  86. }
  87. func (err ErrUserProhibitLogin) Error() string {
  88. return fmt.Sprintf("user is not allowed login [uid: %d, name: %s]", err.UID, err.Name)
  89. }
  90. // ErrUserInactive represents a "ErrUserInactive" kind of error.
  91. type ErrUserInactive struct {
  92. UID int64
  93. Name string
  94. }
  95. // IsErrUserInactive checks if an error is a ErrUserInactive
  96. func IsErrUserInactive(err error) bool {
  97. _, ok := err.(ErrUserInactive)
  98. return ok
  99. }
  100. func (err ErrUserInactive) Error() string {
  101. return fmt.Sprintf("user is inactive [uid: %d, name: %s]", err.UID, err.Name)
  102. }
  103. // ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.
  104. type ErrEmailAlreadyUsed struct {
  105. Email string
  106. }
  107. // IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
  108. func IsErrEmailAlreadyUsed(err error) bool {
  109. _, ok := err.(ErrEmailAlreadyUsed)
  110. return ok
  111. }
  112. func (err ErrEmailAlreadyUsed) Error() string {
  113. return fmt.Sprintf("e-mail already in use [email: %s]", err.Email)
  114. }
  115. // ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.
  116. type ErrOpenIDAlreadyUsed struct {
  117. OpenID string
  118. }
  119. // IsErrOpenIDAlreadyUsed checks if an error is a ErrOpenIDAlreadyUsed.
  120. func IsErrOpenIDAlreadyUsed(err error) bool {
  121. _, ok := err.(ErrOpenIDAlreadyUsed)
  122. return ok
  123. }
  124. func (err ErrOpenIDAlreadyUsed) Error() string {
  125. return fmt.Sprintf("OpenID already in use [oid: %s]", err.OpenID)
  126. }
  127. // ErrUserOwnRepos represents a "UserOwnRepos" kind of error.
  128. type ErrUserOwnRepos struct {
  129. UID int64
  130. }
  131. // IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.
  132. func IsErrUserOwnRepos(err error) bool {
  133. _, ok := err.(ErrUserOwnRepos)
  134. return ok
  135. }
  136. func (err ErrUserOwnRepos) Error() string {
  137. return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
  138. }
  139. // ErrUserHasOrgs represents a "UserHasOrgs" kind of error.
  140. type ErrUserHasOrgs struct {
  141. UID int64
  142. }
  143. // IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.
  144. func IsErrUserHasOrgs(err error) bool {
  145. _, ok := err.(ErrUserHasOrgs)
  146. return ok
  147. }
  148. func (err ErrUserHasOrgs) Error() string {
  149. return fmt.Sprintf("user still has membership of organizations [uid: %d]", err.UID)
  150. }
  151. // ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.
  152. type ErrUserNotAllowedCreateOrg struct {
  153. }
  154. // IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.
  155. func IsErrUserNotAllowedCreateOrg(err error) bool {
  156. _, ok := err.(ErrUserNotAllowedCreateOrg)
  157. return ok
  158. }
  159. func (err ErrUserNotAllowedCreateOrg) Error() string {
  160. return fmt.Sprintf("user is not allowed to create organizations")
  161. }
  162. // ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.
  163. type ErrReachLimitOfRepo struct {
  164. Limit int
  165. }
  166. // IsErrReachLimitOfRepo checks if an error is a ErrReachLimitOfRepo.
  167. func IsErrReachLimitOfRepo(err error) bool {
  168. _, ok := err.(ErrReachLimitOfRepo)
  169. return ok
  170. }
  171. func (err ErrReachLimitOfRepo) Error() string {
  172. return fmt.Sprintf("user has reached maximum limit of repositories [limit: %d]", err.Limit)
  173. }
  174. // __ __.__ __ .__
  175. // / \ / \__| | _|__|
  176. // \ \/\/ / | |/ / |
  177. // \ /| | <| |
  178. // \__/\ / |__|__|_ \__|
  179. // \/ \/
  180. // ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.
  181. type ErrWikiAlreadyExist struct {
  182. Title string
  183. }
  184. // IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
  185. func IsErrWikiAlreadyExist(err error) bool {
  186. _, ok := err.(ErrWikiAlreadyExist)
  187. return ok
  188. }
  189. func (err ErrWikiAlreadyExist) Error() string {
  190. return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
  191. }
  192. // ErrWikiReservedName represents a reserved name error.
  193. type ErrWikiReservedName struct {
  194. Title string
  195. }
  196. // IsErrWikiReservedName checks if an error is an ErrWikiReservedName.
  197. func IsErrWikiReservedName(err error) bool {
  198. _, ok := err.(ErrWikiReservedName)
  199. return ok
  200. }
  201. func (err ErrWikiReservedName) Error() string {
  202. return fmt.Sprintf("wiki title is reserved: %s", err.Title)
  203. }
  204. // ErrWikiInvalidFileName represents an invalid wiki file name.
  205. type ErrWikiInvalidFileName struct {
  206. FileName string
  207. }
  208. // IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.
  209. func IsErrWikiInvalidFileName(err error) bool {
  210. _, ok := err.(ErrWikiInvalidFileName)
  211. return ok
  212. }
  213. func (err ErrWikiInvalidFileName) Error() string {
  214. return fmt.Sprintf("Invalid wiki filename: %s", err.FileName)
  215. }
  216. // __________ ___. .__ .__ ____ __.
  217. // \______ \__ _\_ |__ | | |__| ____ | |/ _|____ ___.__.
  218. // | ___/ | \ __ \| | | |/ ___\ | <_/ __ < | |
  219. // | | | | / \_\ \ |_| \ \___ | | \ ___/\___ |
  220. // |____| |____/|___ /____/__|\___ > |____|__ \___ > ____|
  221. // \/ \/ \/ \/\/
  222. // ErrKeyUnableVerify represents a "KeyUnableVerify" kind of error.
  223. type ErrKeyUnableVerify struct {
  224. Result string
  225. }
  226. // IsErrKeyUnableVerify checks if an error is a ErrKeyUnableVerify.
  227. func IsErrKeyUnableVerify(err error) bool {
  228. _, ok := err.(ErrKeyUnableVerify)
  229. return ok
  230. }
  231. func (err ErrKeyUnableVerify) Error() string {
  232. return fmt.Sprintf("Unable to verify key content [result: %s]", err.Result)
  233. }
  234. // ErrKeyNotExist represents a "KeyNotExist" kind of error.
  235. type ErrKeyNotExist struct {
  236. ID int64
  237. }
  238. // IsErrKeyNotExist checks if an error is a ErrKeyNotExist.
  239. func IsErrKeyNotExist(err error) bool {
  240. _, ok := err.(ErrKeyNotExist)
  241. return ok
  242. }
  243. func (err ErrKeyNotExist) Error() string {
  244. return fmt.Sprintf("public key does not exist [id: %d]", err.ID)
  245. }
  246. // ErrKeyAlreadyExist represents a "KeyAlreadyExist" kind of error.
  247. type ErrKeyAlreadyExist struct {
  248. OwnerID int64
  249. Fingerprint string
  250. Content string
  251. }
  252. // IsErrKeyAlreadyExist checks if an error is a ErrKeyAlreadyExist.
  253. func IsErrKeyAlreadyExist(err error) bool {
  254. _, ok := err.(ErrKeyAlreadyExist)
  255. return ok
  256. }
  257. func (err ErrKeyAlreadyExist) Error() string {
  258. return fmt.Sprintf("public key already exists [owner_id: %d, finter_print: %s, content: %s]",
  259. err.OwnerID, err.Fingerprint, err.Content)
  260. }
  261. // ErrKeyNameAlreadyUsed represents a "KeyNameAlreadyUsed" kind of error.
  262. type ErrKeyNameAlreadyUsed struct {
  263. OwnerID int64
  264. Name string
  265. }
  266. // IsErrKeyNameAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
  267. func IsErrKeyNameAlreadyUsed(err error) bool {
  268. _, ok := err.(ErrKeyNameAlreadyUsed)
  269. return ok
  270. }
  271. func (err ErrKeyNameAlreadyUsed) Error() string {
  272. return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
  273. }
  274. // ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
  275. type ErrGPGNoEmailFound struct {
  276. FailedEmails []string
  277. }
  278. // IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.
  279. func IsErrGPGNoEmailFound(err error) bool {
  280. _, ok := err.(ErrGPGNoEmailFound)
  281. return ok
  282. }
  283. func (err ErrGPGNoEmailFound) Error() string {
  284. return fmt.Sprintf("none of the emails attached to the GPG key could be found: %v", err.FailedEmails)
  285. }
  286. // ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.
  287. type ErrGPGKeyParsing struct {
  288. ParseError error
  289. }
  290. // IsErrGPGKeyParsing checks if an error is a ErrGPGKeyParsing.
  291. func IsErrGPGKeyParsing(err error) bool {
  292. _, ok := err.(ErrGPGKeyParsing)
  293. return ok
  294. }
  295. func (err ErrGPGKeyParsing) Error() string {
  296. return fmt.Sprintf("failed to parse gpg key %s", err.ParseError.Error())
  297. }
  298. // ErrGPGKeyNotExist represents a "GPGKeyNotExist" kind of error.
  299. type ErrGPGKeyNotExist struct {
  300. ID int64
  301. }
  302. // IsErrGPGKeyNotExist checks if an error is a ErrGPGKeyNotExist.
  303. func IsErrGPGKeyNotExist(err error) bool {
  304. _, ok := err.(ErrGPGKeyNotExist)
  305. return ok
  306. }
  307. func (err ErrGPGKeyNotExist) Error() string {
  308. return fmt.Sprintf("public gpg key does not exist [id: %d]", err.ID)
  309. }
  310. // ErrGPGKeyImportNotExist represents a "GPGKeyImportNotExist" kind of error.
  311. type ErrGPGKeyImportNotExist struct {
  312. ID string
  313. }
  314. // IsErrGPGKeyImportNotExist checks if an error is a ErrGPGKeyImportNotExist.
  315. func IsErrGPGKeyImportNotExist(err error) bool {
  316. _, ok := err.(ErrGPGKeyImportNotExist)
  317. return ok
  318. }
  319. func (err ErrGPGKeyImportNotExist) Error() string {
  320. return fmt.Sprintf("public gpg key import does not exist [id: %s]", err.ID)
  321. }
  322. // ErrGPGKeyIDAlreadyUsed represents a "GPGKeyIDAlreadyUsed" kind of error.
  323. type ErrGPGKeyIDAlreadyUsed struct {
  324. KeyID string
  325. }
  326. // IsErrGPGKeyIDAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
  327. func IsErrGPGKeyIDAlreadyUsed(err error) bool {
  328. _, ok := err.(ErrGPGKeyIDAlreadyUsed)
  329. return ok
  330. }
  331. func (err ErrGPGKeyIDAlreadyUsed) Error() string {
  332. return fmt.Sprintf("public key already exists [key_id: %s]", err.KeyID)
  333. }
  334. // ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error.
  335. type ErrGPGKeyAccessDenied struct {
  336. UserID int64
  337. KeyID int64
  338. }
  339. // IsErrGPGKeyAccessDenied checks if an error is a ErrGPGKeyAccessDenied.
  340. func IsErrGPGKeyAccessDenied(err error) bool {
  341. _, ok := err.(ErrGPGKeyAccessDenied)
  342. return ok
  343. }
  344. // Error pretty-prints an error of type ErrGPGKeyAccessDenied.
  345. func (err ErrGPGKeyAccessDenied) Error() string {
  346. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d]",
  347. err.UserID, err.KeyID)
  348. }
  349. // ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error.
  350. type ErrKeyAccessDenied struct {
  351. UserID int64
  352. KeyID int64
  353. Note string
  354. }
  355. // IsErrKeyAccessDenied checks if an error is a ErrKeyAccessDenied.
  356. func IsErrKeyAccessDenied(err error) bool {
  357. _, ok := err.(ErrKeyAccessDenied)
  358. return ok
  359. }
  360. func (err ErrKeyAccessDenied) Error() string {
  361. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d, note: %s]",
  362. err.UserID, err.KeyID, err.Note)
  363. }
  364. // ErrDeployKeyNotExist represents a "DeployKeyNotExist" kind of error.
  365. type ErrDeployKeyNotExist struct {
  366. ID int64
  367. KeyID int64
  368. RepoID int64
  369. }
  370. // IsErrDeployKeyNotExist checks if an error is a ErrDeployKeyNotExist.
  371. func IsErrDeployKeyNotExist(err error) bool {
  372. _, ok := err.(ErrDeployKeyNotExist)
  373. return ok
  374. }
  375. func (err ErrDeployKeyNotExist) Error() string {
  376. return fmt.Sprintf("Deploy key does not exist [id: %d, key_id: %d, repo_id: %d]", err.ID, err.KeyID, err.RepoID)
  377. }
  378. // ErrDeployKeyAlreadyExist represents a "DeployKeyAlreadyExist" kind of error.
  379. type ErrDeployKeyAlreadyExist struct {
  380. KeyID int64
  381. RepoID int64
  382. }
  383. // IsErrDeployKeyAlreadyExist checks if an error is a ErrDeployKeyAlreadyExist.
  384. func IsErrDeployKeyAlreadyExist(err error) bool {
  385. _, ok := err.(ErrDeployKeyAlreadyExist)
  386. return ok
  387. }
  388. func (err ErrDeployKeyAlreadyExist) Error() string {
  389. return fmt.Sprintf("public key already exists [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
  390. }
  391. // ErrDeployKeyNameAlreadyUsed represents a "DeployKeyNameAlreadyUsed" kind of error.
  392. type ErrDeployKeyNameAlreadyUsed struct {
  393. RepoID int64
  394. Name string
  395. }
  396. // IsErrDeployKeyNameAlreadyUsed checks if an error is a ErrDeployKeyNameAlreadyUsed.
  397. func IsErrDeployKeyNameAlreadyUsed(err error) bool {
  398. _, ok := err.(ErrDeployKeyNameAlreadyUsed)
  399. return ok
  400. }
  401. func (err ErrDeployKeyNameAlreadyUsed) Error() string {
  402. return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
  403. }
  404. // _____ ___________ __
  405. // / _ \ ____ ____ ____ ______ _____\__ ___/___ | | __ ____ ____
  406. // / /_\ \_/ ___\/ ___\/ __ \ / ___// ___/ | | / _ \| |/ // __ \ / \
  407. // / | \ \__\ \__\ ___/ \___ \ \___ \ | |( <_> ) <\ ___/| | \
  408. // \____|__ /\___ >___ >___ >____ >____ > |____| \____/|__|_ \\___ >___| /
  409. // \/ \/ \/ \/ \/ \/ \/ \/ \/
  410. // ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.
  411. type ErrAccessTokenNotExist struct {
  412. SHA string
  413. }
  414. // IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.
  415. func IsErrAccessTokenNotExist(err error) bool {
  416. _, ok := err.(ErrAccessTokenNotExist)
  417. return ok
  418. }
  419. func (err ErrAccessTokenNotExist) Error() string {
  420. return fmt.Sprintf("access token does not exist [sha: %s]", err.SHA)
  421. }
  422. // ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.
  423. type ErrAccessTokenEmpty struct {
  424. }
  425. // IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.
  426. func IsErrAccessTokenEmpty(err error) bool {
  427. _, ok := err.(ErrAccessTokenEmpty)
  428. return ok
  429. }
  430. func (err ErrAccessTokenEmpty) Error() string {
  431. return fmt.Sprintf("access token is empty")
  432. }
  433. // ________ .__ __ .__
  434. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  435. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  436. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  437. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  438. // \/ /_____/ \/ \/ \/ \/ \/
  439. // ErrOrgNotExist represents a "OrgNotExist" kind of error.
  440. type ErrOrgNotExist struct {
  441. ID int64
  442. Name string
  443. }
  444. // IsErrOrgNotExist checks if an error is a ErrOrgNotExist.
  445. func IsErrOrgNotExist(err error) bool {
  446. _, ok := err.(ErrOrgNotExist)
  447. return ok
  448. }
  449. func (err ErrOrgNotExist) Error() string {
  450. return fmt.Sprintf("org does not exist [id: %d, name: %s]", err.ID, err.Name)
  451. }
  452. // ErrLastOrgOwner represents a "LastOrgOwner" kind of error.
  453. type ErrLastOrgOwner struct {
  454. UID int64
  455. }
  456. // IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.
  457. func IsErrLastOrgOwner(err error) bool {
  458. _, ok := err.(ErrLastOrgOwner)
  459. return ok
  460. }
  461. func (err ErrLastOrgOwner) Error() string {
  462. return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
  463. }
  464. //.____ ____________________
  465. //| | \_ _____/ _____/
  466. //| | | __) \_____ \
  467. //| |___| \ / \
  468. //|_______ \___ / /_______ /
  469. // \/ \/ \/
  470. // ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
  471. type ErrLFSLockNotExist struct {
  472. ID int64
  473. RepoID int64
  474. Path string
  475. }
  476. // IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.
  477. func IsErrLFSLockNotExist(err error) bool {
  478. _, ok := err.(ErrLFSLockNotExist)
  479. return ok
  480. }
  481. func (err ErrLFSLockNotExist) Error() string {
  482. return fmt.Sprintf("lfs lock does not exist [id: %d, rid: %d, path: %s]", err.ID, err.RepoID, err.Path)
  483. }
  484. // ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.
  485. type ErrLFSUnauthorizedAction struct {
  486. RepoID int64
  487. UserName string
  488. Mode AccessMode
  489. }
  490. // IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.
  491. func IsErrLFSUnauthorizedAction(err error) bool {
  492. _, ok := err.(ErrLFSUnauthorizedAction)
  493. return ok
  494. }
  495. func (err ErrLFSUnauthorizedAction) Error() string {
  496. if err.Mode == AccessModeWrite {
  497. return fmt.Sprintf("User %s doesn't have write access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  498. }
  499. return fmt.Sprintf("User %s doesn't have read access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  500. }
  501. // ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
  502. type ErrLFSLockAlreadyExist struct {
  503. RepoID int64
  504. Path string
  505. }
  506. // IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.
  507. func IsErrLFSLockAlreadyExist(err error) bool {
  508. _, ok := err.(ErrLFSLockAlreadyExist)
  509. return ok
  510. }
  511. func (err ErrLFSLockAlreadyExist) Error() string {
  512. return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
  513. }
  514. // __________ .__ __
  515. // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
  516. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
  517. // | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
  518. // |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
  519. // \/ \/|__| \/ \/
  520. // ErrRepoNotExist represents a "RepoNotExist" kind of error.
  521. type ErrRepoNotExist struct {
  522. ID int64
  523. UID int64
  524. OwnerName string
  525. Name string
  526. }
  527. // IsErrRepoNotExist checks if an error is a ErrRepoNotExist.
  528. func IsErrRepoNotExist(err error) bool {
  529. _, ok := err.(ErrRepoNotExist)
  530. return ok
  531. }
  532. func (err ErrRepoNotExist) Error() string {
  533. return fmt.Sprintf("repository does not exist [id: %d, uid: %d, owner_name: %s, name: %s]",
  534. err.ID, err.UID, err.OwnerName, err.Name)
  535. }
  536. // ErrRepoAlreadyExist represents a "RepoAlreadyExist" kind of error.
  537. type ErrRepoAlreadyExist struct {
  538. Uname string
  539. Name string
  540. }
  541. // IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.
  542. func IsErrRepoAlreadyExist(err error) bool {
  543. _, ok := err.(ErrRepoAlreadyExist)
  544. return ok
  545. }
  546. func (err ErrRepoAlreadyExist) Error() string {
  547. return fmt.Sprintf("repository already exists [uname: %s, name: %s]", err.Uname, err.Name)
  548. }
  549. // ErrRepoRedirectNotExist represents a "RepoRedirectNotExist" kind of error.
  550. type ErrRepoRedirectNotExist struct {
  551. OwnerID int64
  552. RepoName string
  553. }
  554. // IsErrRepoRedirectNotExist check if an error is an ErrRepoRedirectNotExist.
  555. func IsErrRepoRedirectNotExist(err error) bool {
  556. _, ok := err.(ErrRepoRedirectNotExist)
  557. return ok
  558. }
  559. func (err ErrRepoRedirectNotExist) Error() string {
  560. return fmt.Sprintf("repository redirect does not exist [uid: %d, name: %s]", err.OwnerID, err.RepoName)
  561. }
  562. // ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.
  563. type ErrInvalidCloneAddr struct {
  564. IsURLError bool
  565. IsInvalidPath bool
  566. IsPermissionDenied bool
  567. }
  568. // IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
  569. func IsErrInvalidCloneAddr(err error) bool {
  570. _, ok := err.(ErrInvalidCloneAddr)
  571. return ok
  572. }
  573. func (err ErrInvalidCloneAddr) Error() string {
  574. return fmt.Sprintf("invalid clone address [is_url_error: %v, is_invalid_path: %v, is_permission_denied: %v]",
  575. err.IsURLError, err.IsInvalidPath, err.IsPermissionDenied)
  576. }
  577. // ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.
  578. type ErrUpdateTaskNotExist struct {
  579. UUID string
  580. }
  581. // IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.
  582. func IsErrUpdateTaskNotExist(err error) bool {
  583. _, ok := err.(ErrUpdateTaskNotExist)
  584. return ok
  585. }
  586. func (err ErrUpdateTaskNotExist) Error() string {
  587. return fmt.Sprintf("update task does not exist [uuid: %s]", err.UUID)
  588. }
  589. // ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.
  590. type ErrReleaseAlreadyExist struct {
  591. TagName string
  592. }
  593. // IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.
  594. func IsErrReleaseAlreadyExist(err error) bool {
  595. _, ok := err.(ErrReleaseAlreadyExist)
  596. return ok
  597. }
  598. func (err ErrReleaseAlreadyExist) Error() string {
  599. return fmt.Sprintf("release tag already exist [tag_name: %s]", err.TagName)
  600. }
  601. // ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.
  602. type ErrReleaseNotExist struct {
  603. ID int64
  604. TagName string
  605. }
  606. // IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.
  607. func IsErrReleaseNotExist(err error) bool {
  608. _, ok := err.(ErrReleaseNotExist)
  609. return ok
  610. }
  611. func (err ErrReleaseNotExist) Error() string {
  612. return fmt.Sprintf("release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
  613. }
  614. // ErrInvalidTagName represents a "InvalidTagName" kind of error.
  615. type ErrInvalidTagName struct {
  616. TagName string
  617. }
  618. // IsErrInvalidTagName checks if an error is a ErrInvalidTagName.
  619. func IsErrInvalidTagName(err error) bool {
  620. _, ok := err.(ErrInvalidTagName)
  621. return ok
  622. }
  623. func (err ErrInvalidTagName) Error() string {
  624. return fmt.Sprintf("release tag name is not valid [tag_name: %s]", err.TagName)
  625. }
  626. // ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.
  627. type ErrRepoFileAlreadyExists struct {
  628. Path string
  629. }
  630. // IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.
  631. func IsErrRepoFileAlreadyExists(err error) bool {
  632. _, ok := err.(ErrRepoFileAlreadyExists)
  633. return ok
  634. }
  635. func (err ErrRepoFileAlreadyExists) Error() string {
  636. return fmt.Sprintf("repository file already exists [path: %s]", err.Path)
  637. }
  638. // ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.
  639. type ErrRepoFileDoesNotExist struct {
  640. Path string
  641. Name string
  642. }
  643. // IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.
  644. func IsErrRepoFileDoesNotExist(err error) bool {
  645. _, ok := err.(ErrRepoFileDoesNotExist)
  646. return ok
  647. }
  648. func (err ErrRepoFileDoesNotExist) Error() string {
  649. return fmt.Sprintf("repository file does not exist [path: %s]", err.Path)
  650. }
  651. // ErrFilenameInvalid represents a "FilenameInvalid" kind of error.
  652. type ErrFilenameInvalid struct {
  653. Path string
  654. }
  655. // IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.
  656. func IsErrFilenameInvalid(err error) bool {
  657. _, ok := err.(ErrFilenameInvalid)
  658. return ok
  659. }
  660. func (err ErrFilenameInvalid) Error() string {
  661. return fmt.Sprintf("path contains a malformed path component [path: %s]", err.Path)
  662. }
  663. // ErrUserCannotCommit represents "UserCannotCommit" kind of error.
  664. type ErrUserCannotCommit struct {
  665. UserName string
  666. }
  667. // IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.
  668. func IsErrUserCannotCommit(err error) bool {
  669. _, ok := err.(ErrUserCannotCommit)
  670. return ok
  671. }
  672. func (err ErrUserCannotCommit) Error() string {
  673. return fmt.Sprintf("user cannot commit to repo [user: %s]", err.UserName)
  674. }
  675. // ErrFilePathInvalid represents a "FilePathInvalid" kind of error.
  676. type ErrFilePathInvalid struct {
  677. Message string
  678. Path string
  679. Name string
  680. Type git.EntryMode
  681. }
  682. // IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.
  683. func IsErrFilePathInvalid(err error) bool {
  684. _, ok := err.(ErrFilePathInvalid)
  685. return ok
  686. }
  687. func (err ErrFilePathInvalid) Error() string {
  688. if err.Message != "" {
  689. return err.Message
  690. }
  691. return fmt.Sprintf("path is invalid [path: %s]", err.Path)
  692. }
  693. // ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo.
  694. type ErrUserDoesNotHaveAccessToRepo struct {
  695. UserID int64
  696. RepoName string
  697. }
  698. // IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExists.
  699. func IsErrUserDoesNotHaveAccessToRepo(err error) bool {
  700. _, ok := err.(ErrUserDoesNotHaveAccessToRepo)
  701. return ok
  702. }
  703. func (err ErrUserDoesNotHaveAccessToRepo) Error() string {
  704. return fmt.Sprintf("user doesn't have acces to repo [user_id: %d, repo_name: %s]", err.UserID, err.RepoName)
  705. }
  706. // __________ .__
  707. // \______ \____________ ____ ____ | |__
  708. // | | _/\_ __ \__ \ / \_/ ___\| | \
  709. // | | \ | | \// __ \| | \ \___| Y \
  710. // |______ / |__| (____ /___| /\___ >___| /
  711. // \/ \/ \/ \/ \/
  712. // ErrBranchAlreadyExists represents an error that branch with such name already exists.
  713. type ErrBranchAlreadyExists struct {
  714. BranchName string
  715. }
  716. // IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
  717. func IsErrBranchAlreadyExists(err error) bool {
  718. _, ok := err.(ErrBranchAlreadyExists)
  719. return ok
  720. }
  721. func (err ErrBranchAlreadyExists) Error() string {
  722. return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
  723. }
  724. // ErrBranchNameConflict represents an error that branch name conflicts with other branch.
  725. type ErrBranchNameConflict struct {
  726. BranchName string
  727. }
  728. // IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
  729. func IsErrBranchNameConflict(err error) bool {
  730. _, ok := err.(ErrBranchNameConflict)
  731. return ok
  732. }
  733. func (err ErrBranchNameConflict) Error() string {
  734. return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
  735. }
  736. // ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
  737. type ErrNotAllowedToMerge struct {
  738. Reason string
  739. }
  740. // IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
  741. func IsErrNotAllowedToMerge(err error) bool {
  742. _, ok := err.(ErrNotAllowedToMerge)
  743. return ok
  744. }
  745. func (err ErrNotAllowedToMerge) Error() string {
  746. return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
  747. }
  748. // ErrTagAlreadyExists represents an error that tag with such name already exists.
  749. type ErrTagAlreadyExists struct {
  750. TagName string
  751. }
  752. // IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
  753. func IsErrTagAlreadyExists(err error) bool {
  754. _, ok := err.(ErrTagAlreadyExists)
  755. return ok
  756. }
  757. func (err ErrTagAlreadyExists) Error() string {
  758. return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
  759. }
  760. // ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.
  761. type ErrSHADoesNotMatch struct {
  762. Path string
  763. GivenSHA string
  764. CurrentSHA string
  765. }
  766. // IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.
  767. func IsErrSHADoesNotMatch(err error) bool {
  768. _, ok := err.(ErrSHADoesNotMatch)
  769. return ok
  770. }
  771. func (err ErrSHADoesNotMatch) Error() string {
  772. return fmt.Sprintf("sha does not match [given: %s, expected: %s]", err.GivenSHA, err.CurrentSHA)
  773. }
  774. // ErrSHANotFound represents a "SHADoesNotMatch" kind of error.
  775. type ErrSHANotFound struct {
  776. SHA string
  777. }
  778. // IsErrSHANotFound checks if an error is a ErrSHANotFound.
  779. func IsErrSHANotFound(err error) bool {
  780. _, ok := err.(ErrSHANotFound)
  781. return ok
  782. }
  783. func (err ErrSHANotFound) Error() string {
  784. return fmt.Sprintf("sha not found [%s]", err.SHA)
  785. }
  786. // ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.
  787. type ErrCommitIDDoesNotMatch struct {
  788. GivenCommitID string
  789. CurrentCommitID string
  790. }
  791. // IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.
  792. func IsErrCommitIDDoesNotMatch(err error) bool {
  793. _, ok := err.(ErrCommitIDDoesNotMatch)
  794. return ok
  795. }
  796. func (err ErrCommitIDDoesNotMatch) Error() string {
  797. return fmt.Sprintf("file CommitID does not match [given: %s, expected: %s]", err.GivenCommitID, err.CurrentCommitID)
  798. }
  799. // ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.
  800. type ErrSHAOrCommitIDNotProvided struct{}
  801. // IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.
  802. func IsErrSHAOrCommitIDNotProvided(err error) bool {
  803. _, ok := err.(ErrSHAOrCommitIDNotProvided)
  804. return ok
  805. }
  806. func (err ErrSHAOrCommitIDNotProvided) Error() string {
  807. return fmt.Sprintf("a SHA or commmit ID must be proved when updating a file")
  808. }
  809. // __ __ ___. .__ __
  810. // / \ / \ ____\_ |__ | |__ ____ ____ | | __
  811. // \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /
  812. // \ /\ ___/| \_\ \ Y ( <_> | <_> ) <
  813. // \__/\ / \___ >___ /___| /\____/ \____/|__|_ \
  814. // \/ \/ \/ \/ \/
  815. // ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
  816. type ErrWebhookNotExist struct {
  817. ID int64
  818. }
  819. // IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
  820. func IsErrWebhookNotExist(err error) bool {
  821. _, ok := err.(ErrWebhookNotExist)
  822. return ok
  823. }
  824. func (err ErrWebhookNotExist) Error() string {
  825. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  826. }
  827. // .___
  828. // | | ______ ________ __ ____
  829. // | |/ ___// ___/ | \_/ __ \
  830. // | |\___ \ \___ \| | /\ ___/
  831. // |___/____ >____ >____/ \___ >
  832. // \/ \/ \/
  833. // ErrIssueNotExist represents a "IssueNotExist" kind of error.
  834. type ErrIssueNotExist struct {
  835. ID int64
  836. RepoID int64
  837. Index int64
  838. }
  839. // IsErrIssueNotExist checks if an error is a ErrIssueNotExist.
  840. func IsErrIssueNotExist(err error) bool {
  841. _, ok := err.(ErrIssueNotExist)
  842. return ok
  843. }
  844. func (err ErrIssueNotExist) Error() string {
  845. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  846. }
  847. // __________ .__ .__ __________ __
  848. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  849. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  850. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  851. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  852. // \/ \/ |__| \/ \/
  853. // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
  854. type ErrPullRequestNotExist struct {
  855. ID int64
  856. IssueID int64
  857. HeadRepoID int64
  858. BaseRepoID int64
  859. HeadBranch string
  860. BaseBranch string
  861. }
  862. // IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
  863. func IsErrPullRequestNotExist(err error) bool {
  864. _, ok := err.(ErrPullRequestNotExist)
  865. return ok
  866. }
  867. func (err ErrPullRequestNotExist) Error() string {
  868. 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]",
  869. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  870. }
  871. // ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
  872. type ErrPullRequestAlreadyExists struct {
  873. ID int64
  874. IssueID int64
  875. HeadRepoID int64
  876. BaseRepoID int64
  877. HeadBranch string
  878. BaseBranch string
  879. }
  880. // IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
  881. func IsErrPullRequestAlreadyExists(err error) bool {
  882. _, ok := err.(ErrPullRequestAlreadyExists)
  883. return ok
  884. }
  885. // Error does pretty-printing :D
  886. func (err ErrPullRequestAlreadyExists) Error() string {
  887. 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]",
  888. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  889. }
  890. // ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
  891. type ErrInvalidMergeStyle struct {
  892. ID int64
  893. Style MergeStyle
  894. }
  895. // IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.
  896. func IsErrInvalidMergeStyle(err error) bool {
  897. _, ok := err.(ErrInvalidMergeStyle)
  898. return ok
  899. }
  900. func (err ErrInvalidMergeStyle) Error() string {
  901. return fmt.Sprintf("merge strategy is not allowed or is invalid [repo_id: %d, strategy: %s]",
  902. err.ID, err.Style)
  903. }
  904. // _________ __
  905. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  906. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  907. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  908. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  909. // \/ \/ \/ \/ \/
  910. // ErrCommentNotExist represents a "CommentNotExist" kind of error.
  911. type ErrCommentNotExist struct {
  912. ID int64
  913. IssueID int64
  914. }
  915. // IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
  916. func IsErrCommentNotExist(err error) bool {
  917. _, ok := err.(ErrCommentNotExist)
  918. return ok
  919. }
  920. func (err ErrCommentNotExist) Error() string {
  921. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  922. }
  923. // _________ __ __ .__
  924. // / _____// |_ ____ ________ _ _______ _/ |_ ____ | |__
  925. // \_____ \\ __\/ _ \\____ \ \/ \/ /\__ \\ __\/ ___\| | \
  926. // / \| | ( <_> ) |_> > / / __ \| | \ \___| Y \
  927. // /_______ /|__| \____/| __/ \/\_/ (____ /__| \___ >___| /
  928. // \/ |__| \/ \/ \/
  929. // ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.
  930. type ErrStopwatchNotExist struct {
  931. ID int64
  932. }
  933. // IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.
  934. func IsErrStopwatchNotExist(err error) bool {
  935. _, ok := err.(ErrStopwatchNotExist)
  936. return ok
  937. }
  938. func (err ErrStopwatchNotExist) Error() string {
  939. return fmt.Sprintf("stopwatch does not exist [id: %d]", err.ID)
  940. }
  941. // ___________ __ .______________.__
  942. // \__ ___/___________ ____ | | __ ____ __| _/\__ ___/|__| _____ ____
  943. // | | \_ __ \__ \ _/ ___\| |/ // __ \ / __ | | | | |/ \_/ __ \
  944. // | | | | \// __ \\ \___| <\ ___// /_/ | | | | | Y Y \ ___/
  945. // |____| |__| (____ /\___ >__|_ \\___ >____ | |____| |__|__|_| /\___ >
  946. // \/ \/ \/ \/ \/ \/ \/
  947. // ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.
  948. type ErrTrackedTimeNotExist struct {
  949. ID int64
  950. }
  951. // IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.
  952. func IsErrTrackedTimeNotExist(err error) bool {
  953. _, ok := err.(ErrTrackedTimeNotExist)
  954. return ok
  955. }
  956. func (err ErrTrackedTimeNotExist) Error() string {
  957. return fmt.Sprintf("tracked time does not exist [id: %d]", err.ID)
  958. }
  959. // .____ ___. .__
  960. // | | _____ \_ |__ ____ | |
  961. // | | \__ \ | __ \_/ __ \| |
  962. // | |___ / __ \| \_\ \ ___/| |__
  963. // |_______ (____ /___ /\___ >____/
  964. // \/ \/ \/ \/
  965. // ErrLabelNotExist represents a "LabelNotExist" kind of error.
  966. type ErrLabelNotExist struct {
  967. LabelID int64
  968. RepoID int64
  969. }
  970. // IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
  971. func IsErrLabelNotExist(err error) bool {
  972. _, ok := err.(ErrLabelNotExist)
  973. return ok
  974. }
  975. func (err ErrLabelNotExist) Error() string {
  976. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  977. }
  978. // _____ .__.__ __
  979. // / \ |__| | ____ _______/ |_ ____ ____ ____
  980. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  981. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  982. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  983. // \/ \/ \/ \/ \/
  984. // ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.
  985. type ErrMilestoneNotExist struct {
  986. ID int64
  987. RepoID int64
  988. }
  989. // IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
  990. func IsErrMilestoneNotExist(err error) bool {
  991. _, ok := err.(ErrMilestoneNotExist)
  992. return ok
  993. }
  994. func (err ErrMilestoneNotExist) Error() string {
  995. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  996. }
  997. // _____ __ __ .__ __
  998. // / _ \_/ |__/ |______ ____ | |__ _____ ____ _____/ |_
  999. // / /_\ \ __\ __\__ \ _/ ___\| | \ / \_/ __ \ / \ __\
  1000. // / | \ | | | / __ \\ \___| Y \ Y Y \ ___/| | \ |
  1001. // \____|__ /__| |__| (____ /\___ >___| /__|_| /\___ >___| /__|
  1002. // \/ \/ \/ \/ \/ \/ \/
  1003. // ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.
  1004. type ErrAttachmentNotExist struct {
  1005. ID int64
  1006. UUID string
  1007. }
  1008. // IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.
  1009. func IsErrAttachmentNotExist(err error) bool {
  1010. _, ok := err.(ErrAttachmentNotExist)
  1011. return ok
  1012. }
  1013. func (err ErrAttachmentNotExist) Error() string {
  1014. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1015. }
  1016. // .____ .__ _________
  1017. // | | ____ ____ |__| ____ / _____/ ____ __ _________ ____ ____
  1018. // | | / _ \ / ___\| |/ \ \_____ \ / _ \| | \_ __ \_/ ___\/ __ \
  1019. // | |__( <_> ) /_/ > | | \ / ( <_> ) | /| | \/\ \__\ ___/
  1020. // |_______ \____/\___ /|__|___| / /_______ /\____/|____/ |__| \___ >___ >
  1021. // \/ /_____/ \/ \/ \/ \/
  1022. // ErrLoginSourceNotExist represents a "LoginSourceNotExist" kind of error.
  1023. type ErrLoginSourceNotExist struct {
  1024. ID int64
  1025. }
  1026. // IsErrLoginSourceNotExist checks if an error is a ErrLoginSourceNotExist.
  1027. func IsErrLoginSourceNotExist(err error) bool {
  1028. _, ok := err.(ErrLoginSourceNotExist)
  1029. return ok
  1030. }
  1031. func (err ErrLoginSourceNotExist) Error() string {
  1032. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  1033. }
  1034. // ErrLoginSourceAlreadyExist represents a "LoginSourceAlreadyExist" kind of error.
  1035. type ErrLoginSourceAlreadyExist struct {
  1036. Name string
  1037. }
  1038. // IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.
  1039. func IsErrLoginSourceAlreadyExist(err error) bool {
  1040. _, ok := err.(ErrLoginSourceAlreadyExist)
  1041. return ok
  1042. }
  1043. func (err ErrLoginSourceAlreadyExist) Error() string {
  1044. return fmt.Sprintf("login source already exists [name: %s]", err.Name)
  1045. }
  1046. // ErrLoginSourceInUse represents a "LoginSourceInUse" kind of error.
  1047. type ErrLoginSourceInUse struct {
  1048. ID int64
  1049. }
  1050. // IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.
  1051. func IsErrLoginSourceInUse(err error) bool {
  1052. _, ok := err.(ErrLoginSourceInUse)
  1053. return ok
  1054. }
  1055. func (err ErrLoginSourceInUse) Error() string {
  1056. return fmt.Sprintf("login source is still used by some users [id: %d]", err.ID)
  1057. }
  1058. // ___________
  1059. // \__ ___/___ _____ _____
  1060. // | |_/ __ \\__ \ / \
  1061. // | |\ ___/ / __ \| Y Y \
  1062. // |____| \___ >____ /__|_| /
  1063. // \/ \/ \/
  1064. // ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
  1065. type ErrTeamAlreadyExist struct {
  1066. OrgID int64
  1067. Name string
  1068. }
  1069. // IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
  1070. func IsErrTeamAlreadyExist(err error) bool {
  1071. _, ok := err.(ErrTeamAlreadyExist)
  1072. return ok
  1073. }
  1074. func (err ErrTeamAlreadyExist) Error() string {
  1075. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  1076. }
  1077. //
  1078. // Two-factor authentication
  1079. //
  1080. // ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication.
  1081. type ErrTwoFactorNotEnrolled struct {
  1082. UID int64
  1083. }
  1084. // IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled.
  1085. func IsErrTwoFactorNotEnrolled(err error) bool {
  1086. _, ok := err.(ErrTwoFactorNotEnrolled)
  1087. return ok
  1088. }
  1089. func (err ErrTwoFactorNotEnrolled) Error() string {
  1090. return fmt.Sprintf("user not enrolled in 2FA [uid: %d]", err.UID)
  1091. }
  1092. // ____ ___ .__ .___
  1093. // | | \______ | | _________ __| _/
  1094. // | | /\____ \| | / _ \__ \ / __ |
  1095. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  1096. // |______/ | __/|____/\____(____ /\____ |
  1097. // |__| \/ \/
  1098. //
  1099. // ErrUploadNotExist represents a "UploadNotExist" kind of error.
  1100. type ErrUploadNotExist struct {
  1101. ID int64
  1102. UUID string
  1103. }
  1104. // IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
  1105. func IsErrUploadNotExist(err error) bool {
  1106. _, ok := err.(ErrAttachmentNotExist)
  1107. return ok
  1108. }
  1109. func (err ErrUploadNotExist) Error() string {
  1110. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1111. }
  1112. // ___________ __ .__ .____ .__ ____ ___
  1113. // \_ _____/__ ____/ |_ ___________ ____ _____ | | | | ____ ____ |__| ____ | | \______ ___________
  1114. // | __)_\ \/ /\ __\/ __ \_ __ \/ \\__ \ | | | | / _ \ / ___\| |/ \ | | / ___// __ \_ __ \
  1115. // | \> < | | \ ___/| | \/ | \/ __ \| |__ | |__( <_> ) /_/ > | | \ | | /\___ \\ ___/| | \/
  1116. // /_______ /__/\_ \ |__| \___ >__| |___| (____ /____/ |_______ \____/\___ /|__|___| / |______//____ >\___ >__|
  1117. // \/ \/ \/ \/ \/ \/ /_____/ \/ \/ \/
  1118. // ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
  1119. type ErrExternalLoginUserAlreadyExist struct {
  1120. ExternalID string
  1121. UserID int64
  1122. LoginSourceID int64
  1123. }
  1124. // IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.
  1125. func IsErrExternalLoginUserAlreadyExist(err error) bool {
  1126. _, ok := err.(ErrExternalLoginUserAlreadyExist)
  1127. return ok
  1128. }
  1129. func (err ErrExternalLoginUserAlreadyExist) Error() string {
  1130. return fmt.Sprintf("external login user already exists [externalID: %s, userID: %d, loginSourceID: %d]", err.ExternalID, err.UserID, err.LoginSourceID)
  1131. }
  1132. // ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
  1133. type ErrExternalLoginUserNotExist struct {
  1134. UserID int64
  1135. LoginSourceID int64
  1136. }
  1137. // IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.
  1138. func IsErrExternalLoginUserNotExist(err error) bool {
  1139. _, ok := err.(ErrExternalLoginUserNotExist)
  1140. return ok
  1141. }
  1142. func (err ErrExternalLoginUserNotExist) Error() string {
  1143. return fmt.Sprintf("external login user link does not exists [userID: %d, loginSourceID: %d]", err.UserID, err.LoginSourceID)
  1144. }
  1145. // ____ ________________________________ .__ __ __ .__
  1146. // | | \_____ \_ _____/\______ \ ____ ____ |__| _______/ |_____________ _/ |_|__| ____ ____
  1147. // | | // ____/| __) | _// __ \ / ___\| |/ ___/\ __\_ __ \__ \\ __\ |/ _ \ / \
  1148. // | | // \| \ | | \ ___// /_/ > |\___ \ | | | | \// __ \| | | ( <_> ) | \
  1149. // |______/ \_______ \___ / |____|_ /\___ >___ /|__/____ > |__| |__| (____ /__| |__|\____/|___| /
  1150. // \/ \/ \/ \/_____/ \/ \/ \/
  1151. // ErrU2FRegistrationNotExist represents a "ErrU2FRegistrationNotExist" kind of error.
  1152. type ErrU2FRegistrationNotExist struct {
  1153. ID int64
  1154. }
  1155. func (err ErrU2FRegistrationNotExist) Error() string {
  1156. return fmt.Sprintf("U2F registration does not exist [id: %d]", err.ID)
  1157. }
  1158. // IsErrU2FRegistrationNotExist checks if an error is a ErrU2FRegistrationNotExist.
  1159. func IsErrU2FRegistrationNotExist(err error) bool {
  1160. _, ok := err.(ErrU2FRegistrationNotExist)
  1161. return ok
  1162. }
  1163. // .___ ________ .___ .__
  1164. // | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
  1165. // | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
  1166. // | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
  1167. // |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
  1168. // \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
  1169. // ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
  1170. type ErrDependencyExists struct {
  1171. IssueID int64
  1172. DependencyID int64
  1173. }
  1174. // IsErrDependencyExists checks if an error is a ErrDependencyExists.
  1175. func IsErrDependencyExists(err error) bool {
  1176. _, ok := err.(ErrDependencyExists)
  1177. return ok
  1178. }
  1179. func (err ErrDependencyExists) Error() string {
  1180. return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1181. }
  1182. // ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
  1183. type ErrDependencyNotExists struct {
  1184. IssueID int64
  1185. DependencyID int64
  1186. }
  1187. // IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
  1188. func IsErrDependencyNotExists(err error) bool {
  1189. _, ok := err.(ErrDependencyNotExists)
  1190. return ok
  1191. }
  1192. func (err ErrDependencyNotExists) Error() string {
  1193. return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1194. }
  1195. // ErrCircularDependency represents a "DependencyCircular" kind of error.
  1196. type ErrCircularDependency struct {
  1197. IssueID int64
  1198. DependencyID int64
  1199. }
  1200. // IsErrCircularDependency checks if an error is a ErrCircularDependency.
  1201. func IsErrCircularDependency(err error) bool {
  1202. _, ok := err.(ErrCircularDependency)
  1203. return ok
  1204. }
  1205. func (err ErrCircularDependency) Error() string {
  1206. return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1207. }
  1208. // ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
  1209. type ErrDependenciesLeft struct {
  1210. IssueID int64
  1211. }
  1212. // IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
  1213. func IsErrDependenciesLeft(err error) bool {
  1214. _, ok := err.(ErrDependenciesLeft)
  1215. return ok
  1216. }
  1217. func (err ErrDependenciesLeft) Error() string {
  1218. return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
  1219. }
  1220. // ErrUnknownDependencyType represents an error where an unknown dependency type was passed
  1221. type ErrUnknownDependencyType struct {
  1222. Type DependencyType
  1223. }
  1224. // IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
  1225. func IsErrUnknownDependencyType(err error) bool {
  1226. _, ok := err.(ErrUnknownDependencyType)
  1227. return ok
  1228. }
  1229. func (err ErrUnknownDependencyType) Error() string {
  1230. return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
  1231. }
  1232. // __________ .__
  1233. // \______ \ _______ _|__| ______ _ __
  1234. // | _// __ \ \/ / |/ __ \ \/ \/ /
  1235. // | | \ ___/\ /| \ ___/\ /
  1236. // |____|_ /\___ >\_/ |__|\___ >\/\_/
  1237. // \/ \/ \/
  1238. // ErrReviewNotExist represents a "ReviewNotExist" kind of error.
  1239. type ErrReviewNotExist struct {
  1240. ID int64
  1241. }
  1242. // IsErrReviewNotExist checks if an error is a ErrReviewNotExist.
  1243. func IsErrReviewNotExist(err error) bool {
  1244. _, ok := err.(ErrReviewNotExist)
  1245. return ok
  1246. }
  1247. func (err ErrReviewNotExist) Error() string {
  1248. return fmt.Sprintf("review does not exist [id: %d]", err.ID)
  1249. }
  1250. // ________ _____ __ .__
  1251. // \_____ \ / _ \ __ ___/ |_| |__
  1252. // / | \ / /_\ \| | \ __\ | \
  1253. // / | \/ | \ | /| | | Y \
  1254. // \_______ /\____|__ /____/ |__| |___| /
  1255. // \/ \/ \/
  1256. // ErrOAuthClientIDInvalid will be thrown if client id cannot be found
  1257. type ErrOAuthClientIDInvalid struct {
  1258. ClientID string
  1259. }
  1260. // IsErrOauthClientIDInvalid checks if an error is a ErrReviewNotExist.
  1261. func IsErrOauthClientIDInvalid(err error) bool {
  1262. _, ok := err.(ErrOAuthClientIDInvalid)
  1263. return ok
  1264. }
  1265. // Error returns the error message
  1266. func (err ErrOAuthClientIDInvalid) Error() string {
  1267. return fmt.Sprintf("Client ID invalid [Client ID: %s]", err.ClientID)
  1268. }
  1269. // ErrOAuthApplicationNotFound will be thrown if id cannot be found
  1270. type ErrOAuthApplicationNotFound struct {
  1271. ID int64
  1272. }
  1273. // IsErrOAuthApplicationNotFound checks if an error is a ErrReviewNotExist.
  1274. func IsErrOAuthApplicationNotFound(err error) bool {
  1275. _, ok := err.(ErrOAuthApplicationNotFound)
  1276. return ok
  1277. }
  1278. // Error returns the error message
  1279. func (err ErrOAuthApplicationNotFound) Error() string {
  1280. return fmt.Sprintf("OAuth application not found [ID: %d]", err.ID)
  1281. }