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

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