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

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