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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018
  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 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. // ErrForkAlreadyExist represents a "ForkAlreadyExist" kind of error.
  606. type ErrForkAlreadyExist struct {
  607. Uname string
  608. RepoName string
  609. ForkName string
  610. }
  611. // IsErrForkAlreadyExist checks if an error is an ErrForkAlreadyExist.
  612. func IsErrForkAlreadyExist(err error) bool {
  613. _, ok := err.(ErrForkAlreadyExist)
  614. return ok
  615. }
  616. func (err ErrForkAlreadyExist) Error() string {
  617. return fmt.Sprintf("repository is already forked by user [uname: %s, repo path: %s, fork path: %s]", err.Uname, err.RepoName, err.ForkName)
  618. }
  619. // ErrRepoRedirectNotExist represents a "RepoRedirectNotExist" kind of error.
  620. type ErrRepoRedirectNotExist struct {
  621. OwnerID int64
  622. RepoName string
  623. }
  624. // IsErrRepoRedirectNotExist check if an error is an ErrRepoRedirectNotExist.
  625. func IsErrRepoRedirectNotExist(err error) bool {
  626. _, ok := err.(ErrRepoRedirectNotExist)
  627. return ok
  628. }
  629. func (err ErrRepoRedirectNotExist) Error() string {
  630. return fmt.Sprintf("repository redirect does not exist [uid: %d, name: %s]", err.OwnerID, err.RepoName)
  631. }
  632. // ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.
  633. type ErrInvalidCloneAddr struct {
  634. IsURLError bool
  635. IsInvalidPath bool
  636. IsPermissionDenied bool
  637. }
  638. // IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
  639. func IsErrInvalidCloneAddr(err error) bool {
  640. _, ok := err.(ErrInvalidCloneAddr)
  641. return ok
  642. }
  643. func (err ErrInvalidCloneAddr) Error() string {
  644. return fmt.Sprintf("invalid clone address [is_url_error: %v, is_invalid_path: %v, is_permission_denied: %v]",
  645. err.IsURLError, err.IsInvalidPath, err.IsPermissionDenied)
  646. }
  647. // ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.
  648. type ErrUpdateTaskNotExist struct {
  649. UUID string
  650. }
  651. // IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.
  652. func IsErrUpdateTaskNotExist(err error) bool {
  653. _, ok := err.(ErrUpdateTaskNotExist)
  654. return ok
  655. }
  656. func (err ErrUpdateTaskNotExist) Error() string {
  657. return fmt.Sprintf("update task does not exist [uuid: %s]", err.UUID)
  658. }
  659. // ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.
  660. type ErrReleaseAlreadyExist struct {
  661. TagName string
  662. }
  663. // IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.
  664. func IsErrReleaseAlreadyExist(err error) bool {
  665. _, ok := err.(ErrReleaseAlreadyExist)
  666. return ok
  667. }
  668. func (err ErrReleaseAlreadyExist) Error() string {
  669. return fmt.Sprintf("release tag already exist [tag_name: %s]", err.TagName)
  670. }
  671. // ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.
  672. type ErrReleaseNotExist struct {
  673. ID int64
  674. TagName string
  675. }
  676. // IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.
  677. func IsErrReleaseNotExist(err error) bool {
  678. _, ok := err.(ErrReleaseNotExist)
  679. return ok
  680. }
  681. func (err ErrReleaseNotExist) Error() string {
  682. return fmt.Sprintf("release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
  683. }
  684. // ErrInvalidTagName represents a "InvalidTagName" kind of error.
  685. type ErrInvalidTagName struct {
  686. TagName string
  687. }
  688. // IsErrInvalidTagName checks if an error is a ErrInvalidTagName.
  689. func IsErrInvalidTagName(err error) bool {
  690. _, ok := err.(ErrInvalidTagName)
  691. return ok
  692. }
  693. func (err ErrInvalidTagName) Error() string {
  694. return fmt.Sprintf("release tag name is not valid [tag_name: %s]", err.TagName)
  695. }
  696. // ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.
  697. type ErrRepoFileAlreadyExists struct {
  698. Path string
  699. }
  700. // IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.
  701. func IsErrRepoFileAlreadyExists(err error) bool {
  702. _, ok := err.(ErrRepoFileAlreadyExists)
  703. return ok
  704. }
  705. func (err ErrRepoFileAlreadyExists) Error() string {
  706. return fmt.Sprintf("repository file already exists [path: %s]", err.Path)
  707. }
  708. // ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.
  709. type ErrRepoFileDoesNotExist struct {
  710. Path string
  711. Name string
  712. }
  713. // IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.
  714. func IsErrRepoFileDoesNotExist(err error) bool {
  715. _, ok := err.(ErrRepoFileDoesNotExist)
  716. return ok
  717. }
  718. func (err ErrRepoFileDoesNotExist) Error() string {
  719. return fmt.Sprintf("repository file does not exist [path: %s]", err.Path)
  720. }
  721. // ErrFilenameInvalid represents a "FilenameInvalid" kind of error.
  722. type ErrFilenameInvalid struct {
  723. Path string
  724. }
  725. // IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.
  726. func IsErrFilenameInvalid(err error) bool {
  727. _, ok := err.(ErrFilenameInvalid)
  728. return ok
  729. }
  730. func (err ErrFilenameInvalid) Error() string {
  731. return fmt.Sprintf("path contains a malformed path component [path: %s]", err.Path)
  732. }
  733. // ErrUserCannotCommit represents "UserCannotCommit" kind of error.
  734. type ErrUserCannotCommit struct {
  735. UserName string
  736. }
  737. // IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.
  738. func IsErrUserCannotCommit(err error) bool {
  739. _, ok := err.(ErrUserCannotCommit)
  740. return ok
  741. }
  742. func (err ErrUserCannotCommit) Error() string {
  743. return fmt.Sprintf("user cannot commit to repo [user: %s]", err.UserName)
  744. }
  745. // ErrFilePathInvalid represents a "FilePathInvalid" kind of error.
  746. type ErrFilePathInvalid struct {
  747. Message string
  748. Path string
  749. Name string
  750. Type git.EntryMode
  751. }
  752. // IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.
  753. func IsErrFilePathInvalid(err error) bool {
  754. _, ok := err.(ErrFilePathInvalid)
  755. return ok
  756. }
  757. func (err ErrFilePathInvalid) Error() string {
  758. if err.Message != "" {
  759. return err.Message
  760. }
  761. return fmt.Sprintf("path is invalid [path: %s]", err.Path)
  762. }
  763. // ErrFilePathProtected represents a "FilePathProtected" kind of error.
  764. type ErrFilePathProtected struct {
  765. Message string
  766. Path string
  767. }
  768. // IsErrFilePathProtected checks if an error is an ErrFilePathProtected.
  769. func IsErrFilePathProtected(err error) bool {
  770. _, ok := err.(ErrFilePathProtected)
  771. return ok
  772. }
  773. func (err ErrFilePathProtected) Error() string {
  774. if err.Message != "" {
  775. return err.Message
  776. }
  777. return fmt.Sprintf("path is protected and can not be changed [path: %s]", err.Path)
  778. }
  779. // ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo.
  780. type ErrUserDoesNotHaveAccessToRepo struct {
  781. UserID int64
  782. RepoName string
  783. }
  784. // IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExists.
  785. func IsErrUserDoesNotHaveAccessToRepo(err error) bool {
  786. _, ok := err.(ErrUserDoesNotHaveAccessToRepo)
  787. return ok
  788. }
  789. func (err ErrUserDoesNotHaveAccessToRepo) Error() string {
  790. return fmt.Sprintf("user doesn't have acces to repo [user_id: %d, repo_name: %s]", err.UserID, err.RepoName)
  791. }
  792. // ErrWontSign explains the first reason why a commit would not be signed
  793. // There may be other reasons - this is just the first reason found
  794. type ErrWontSign struct {
  795. Reason signingMode
  796. }
  797. func (e *ErrWontSign) Error() string {
  798. return fmt.Sprintf("wont sign: %s", e.Reason)
  799. }
  800. // IsErrWontSign checks if an error is a ErrWontSign
  801. func IsErrWontSign(err error) bool {
  802. _, ok := err.(*ErrWontSign)
  803. return ok
  804. }
  805. // __________ .__
  806. // \______ \____________ ____ ____ | |__
  807. // | | _/\_ __ \__ \ / \_/ ___\| | \
  808. // | | \ | | \// __ \| | \ \___| Y \
  809. // |______ / |__| (____ /___| /\___ >___| /
  810. // \/ \/ \/ \/ \/
  811. // ErrBranchDoesNotExist represents an error that branch with such name does not exist.
  812. type ErrBranchDoesNotExist struct {
  813. BranchName string
  814. }
  815. // IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.
  816. func IsErrBranchDoesNotExist(err error) bool {
  817. _, ok := err.(ErrBranchDoesNotExist)
  818. return ok
  819. }
  820. func (err ErrBranchDoesNotExist) Error() string {
  821. return fmt.Sprintf("branch does not exist [name: %s]", err.BranchName)
  822. }
  823. // ErrBranchAlreadyExists represents an error that branch with such name already exists.
  824. type ErrBranchAlreadyExists struct {
  825. BranchName string
  826. }
  827. // IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
  828. func IsErrBranchAlreadyExists(err error) bool {
  829. _, ok := err.(ErrBranchAlreadyExists)
  830. return ok
  831. }
  832. func (err ErrBranchAlreadyExists) Error() string {
  833. return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
  834. }
  835. // ErrBranchNameConflict represents an error that branch name conflicts with other branch.
  836. type ErrBranchNameConflict struct {
  837. BranchName string
  838. }
  839. // IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
  840. func IsErrBranchNameConflict(err error) bool {
  841. _, ok := err.(ErrBranchNameConflict)
  842. return ok
  843. }
  844. func (err ErrBranchNameConflict) Error() string {
  845. return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
  846. }
  847. // ErrBranchesEqual represents an error that branch name conflicts with other branch.
  848. type ErrBranchesEqual struct {
  849. BaseBranchName string
  850. HeadBranchName string
  851. }
  852. // IsErrBranchesEqual checks if an error is an ErrBranchesEqual.
  853. func IsErrBranchesEqual(err error) bool {
  854. _, ok := err.(ErrBranchesEqual)
  855. return ok
  856. }
  857. func (err ErrBranchesEqual) Error() string {
  858. return fmt.Sprintf("branches are equal [head: %sm base: %s]", err.HeadBranchName, err.BaseBranchName)
  859. }
  860. // ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
  861. type ErrNotAllowedToMerge struct {
  862. Reason string
  863. }
  864. // IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
  865. func IsErrNotAllowedToMerge(err error) bool {
  866. _, ok := err.(ErrNotAllowedToMerge)
  867. return ok
  868. }
  869. func (err ErrNotAllowedToMerge) Error() string {
  870. return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
  871. }
  872. // ErrTagAlreadyExists represents an error that tag with such name already exists.
  873. type ErrTagAlreadyExists struct {
  874. TagName string
  875. }
  876. // IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
  877. func IsErrTagAlreadyExists(err error) bool {
  878. _, ok := err.(ErrTagAlreadyExists)
  879. return ok
  880. }
  881. func (err ErrTagAlreadyExists) Error() string {
  882. return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
  883. }
  884. // ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.
  885. type ErrSHADoesNotMatch struct {
  886. Path string
  887. GivenSHA string
  888. CurrentSHA string
  889. }
  890. // IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.
  891. func IsErrSHADoesNotMatch(err error) bool {
  892. _, ok := err.(ErrSHADoesNotMatch)
  893. return ok
  894. }
  895. func (err ErrSHADoesNotMatch) Error() string {
  896. return fmt.Sprintf("sha does not match [given: %s, expected: %s]", err.GivenSHA, err.CurrentSHA)
  897. }
  898. // ErrSHANotFound represents a "SHADoesNotMatch" kind of error.
  899. type ErrSHANotFound struct {
  900. SHA string
  901. }
  902. // IsErrSHANotFound checks if an error is a ErrSHANotFound.
  903. func IsErrSHANotFound(err error) bool {
  904. _, ok := err.(ErrSHANotFound)
  905. return ok
  906. }
  907. func (err ErrSHANotFound) Error() string {
  908. return fmt.Sprintf("sha not found [%s]", err.SHA)
  909. }
  910. // ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.
  911. type ErrCommitIDDoesNotMatch struct {
  912. GivenCommitID string
  913. CurrentCommitID string
  914. }
  915. // IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.
  916. func IsErrCommitIDDoesNotMatch(err error) bool {
  917. _, ok := err.(ErrCommitIDDoesNotMatch)
  918. return ok
  919. }
  920. func (err ErrCommitIDDoesNotMatch) Error() string {
  921. return fmt.Sprintf("file CommitID does not match [given: %s, expected: %s]", err.GivenCommitID, err.CurrentCommitID)
  922. }
  923. // ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.
  924. type ErrSHAOrCommitIDNotProvided struct{}
  925. // IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.
  926. func IsErrSHAOrCommitIDNotProvided(err error) bool {
  927. _, ok := err.(ErrSHAOrCommitIDNotProvided)
  928. return ok
  929. }
  930. func (err ErrSHAOrCommitIDNotProvided) Error() string {
  931. return "a SHA or commmit ID must be proved when updating a file"
  932. }
  933. // __ __ ___. .__ __
  934. // / \ / \ ____\_ |__ | |__ ____ ____ | | __
  935. // \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /
  936. // \ /\ ___/| \_\ \ Y ( <_> | <_> ) <
  937. // \__/\ / \___ >___ /___| /\____/ \____/|__|_ \
  938. // \/ \/ \/ \/ \/
  939. // ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
  940. type ErrWebhookNotExist struct {
  941. ID int64
  942. }
  943. // IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
  944. func IsErrWebhookNotExist(err error) bool {
  945. _, ok := err.(ErrWebhookNotExist)
  946. return ok
  947. }
  948. func (err ErrWebhookNotExist) Error() string {
  949. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  950. }
  951. // .___
  952. // | | ______ ________ __ ____
  953. // | |/ ___// ___/ | \_/ __ \
  954. // | |\___ \ \___ \| | /\ ___/
  955. // |___/____ >____ >____/ \___ >
  956. // \/ \/ \/
  957. // ErrIssueNotExist represents a "IssueNotExist" kind of error.
  958. type ErrIssueNotExist struct {
  959. ID int64
  960. RepoID int64
  961. Index int64
  962. }
  963. // IsErrIssueNotExist checks if an error is a ErrIssueNotExist.
  964. func IsErrIssueNotExist(err error) bool {
  965. _, ok := err.(ErrIssueNotExist)
  966. return ok
  967. }
  968. func (err ErrIssueNotExist) Error() string {
  969. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  970. }
  971. // ErrIssueIsClosed represents a "IssueIsClosed" kind of error.
  972. type ErrIssueIsClosed struct {
  973. ID int64
  974. RepoID int64
  975. Index int64
  976. }
  977. // IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.
  978. func IsErrIssueIsClosed(err error) bool {
  979. _, ok := err.(ErrIssueIsClosed)
  980. return ok
  981. }
  982. func (err ErrIssueIsClosed) Error() string {
  983. return fmt.Sprintf("issue is closed [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  984. }
  985. // ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.
  986. type ErrIssueLabelTemplateLoad struct {
  987. TemplateFile string
  988. OriginalError error
  989. }
  990. // IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.
  991. func IsErrIssueLabelTemplateLoad(err error) bool {
  992. _, ok := err.(ErrIssueLabelTemplateLoad)
  993. return ok
  994. }
  995. func (err ErrIssueLabelTemplateLoad) Error() string {
  996. return fmt.Sprintf("Failed to load label template file '%s': %v", err.TemplateFile, err.OriginalError)
  997. }
  998. // ErrNewIssueInsert is used when the INSERT statement in newIssue fails
  999. type ErrNewIssueInsert struct {
  1000. OriginalError error
  1001. }
  1002. // IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.
  1003. func IsErrNewIssueInsert(err error) bool {
  1004. _, ok := err.(ErrNewIssueInsert)
  1005. return ok
  1006. }
  1007. func (err ErrNewIssueInsert) Error() string {
  1008. return err.OriginalError.Error()
  1009. }
  1010. // ErrIssueWasClosed is used when close a closed issue
  1011. type ErrIssueWasClosed struct {
  1012. ID int64
  1013. Index int64
  1014. }
  1015. // IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.
  1016. func IsErrIssueWasClosed(err error) bool {
  1017. _, ok := err.(ErrIssueWasClosed)
  1018. return ok
  1019. }
  1020. func (err ErrIssueWasClosed) Error() string {
  1021. return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index)
  1022. }
  1023. // ErrPullWasClosed is used close a closed pull request
  1024. type ErrPullWasClosed struct {
  1025. ID int64
  1026. Index int64
  1027. }
  1028. // IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed.
  1029. func IsErrPullWasClosed(err error) bool {
  1030. _, ok := err.(ErrPullWasClosed)
  1031. return ok
  1032. }
  1033. func (err ErrPullWasClosed) Error() string {
  1034. return fmt.Sprintf("Pull request [%d] %d was already closed", err.ID, err.Index)
  1035. }
  1036. // ErrForbiddenIssueReaction is used when a forbidden reaction was try to created
  1037. type ErrForbiddenIssueReaction struct {
  1038. Reaction string
  1039. }
  1040. // IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.
  1041. func IsErrForbiddenIssueReaction(err error) bool {
  1042. _, ok := err.(ErrForbiddenIssueReaction)
  1043. return ok
  1044. }
  1045. func (err ErrForbiddenIssueReaction) Error() string {
  1046. return fmt.Sprintf("'%s' is not an allowed reaction", err.Reaction)
  1047. }
  1048. // ErrReactionAlreadyExist is used when a existing reaction was try to created
  1049. type ErrReactionAlreadyExist struct {
  1050. Reaction string
  1051. }
  1052. // IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist.
  1053. func IsErrReactionAlreadyExist(err error) bool {
  1054. _, ok := err.(ErrReactionAlreadyExist)
  1055. return ok
  1056. }
  1057. func (err ErrReactionAlreadyExist) Error() string {
  1058. return fmt.Sprintf("reaction '%s' already exists", err.Reaction)
  1059. }
  1060. // __________ .__ .__ __________ __
  1061. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  1062. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  1063. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  1064. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  1065. // \/ \/ |__| \/ \/
  1066. // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
  1067. type ErrPullRequestNotExist struct {
  1068. ID int64
  1069. IssueID int64
  1070. HeadRepoID int64
  1071. BaseRepoID int64
  1072. HeadBranch string
  1073. BaseBranch string
  1074. }
  1075. // IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
  1076. func IsErrPullRequestNotExist(err error) bool {
  1077. _, ok := err.(ErrPullRequestNotExist)
  1078. return ok
  1079. }
  1080. func (err ErrPullRequestNotExist) Error() string {
  1081. 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]",
  1082. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1083. }
  1084. // ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
  1085. type ErrPullRequestAlreadyExists struct {
  1086. ID int64
  1087. IssueID int64
  1088. HeadRepoID int64
  1089. BaseRepoID int64
  1090. HeadBranch string
  1091. BaseBranch string
  1092. }
  1093. // IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
  1094. func IsErrPullRequestAlreadyExists(err error) bool {
  1095. _, ok := err.(ErrPullRequestAlreadyExists)
  1096. return ok
  1097. }
  1098. // Error does pretty-printing :D
  1099. func (err ErrPullRequestAlreadyExists) Error() string {
  1100. 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]",
  1101. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1102. }
  1103. // ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error
  1104. type ErrPullRequestHeadRepoMissing struct {
  1105. ID int64
  1106. HeadRepoID int64
  1107. }
  1108. // IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.
  1109. func IsErrErrPullRequestHeadRepoMissing(err error) bool {
  1110. _, ok := err.(ErrPullRequestHeadRepoMissing)
  1111. return ok
  1112. }
  1113. // Error does pretty-printing :D
  1114. func (err ErrPullRequestHeadRepoMissing) Error() string {
  1115. return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]",
  1116. err.ID, err.HeadRepoID)
  1117. }
  1118. // ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
  1119. type ErrInvalidMergeStyle struct {
  1120. ID int64
  1121. Style MergeStyle
  1122. }
  1123. // IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.
  1124. func IsErrInvalidMergeStyle(err error) bool {
  1125. _, ok := err.(ErrInvalidMergeStyle)
  1126. return ok
  1127. }
  1128. func (err ErrInvalidMergeStyle) Error() string {
  1129. return fmt.Sprintf("merge strategy is not allowed or is invalid [repo_id: %d, strategy: %s]",
  1130. err.ID, err.Style)
  1131. }
  1132. // ErrMergeConflicts represents an error if merging fails with a conflict
  1133. type ErrMergeConflicts struct {
  1134. Style MergeStyle
  1135. StdOut string
  1136. StdErr string
  1137. Err error
  1138. }
  1139. // IsErrMergeConflicts checks if an error is a ErrMergeConflicts.
  1140. func IsErrMergeConflicts(err error) bool {
  1141. _, ok := err.(ErrMergeConflicts)
  1142. return ok
  1143. }
  1144. func (err ErrMergeConflicts) Error() string {
  1145. return fmt.Sprintf("Merge Conflict Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1146. }
  1147. // ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories
  1148. type ErrMergeUnrelatedHistories struct {
  1149. Style MergeStyle
  1150. StdOut string
  1151. StdErr string
  1152. Err error
  1153. }
  1154. // IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.
  1155. func IsErrMergeUnrelatedHistories(err error) bool {
  1156. _, ok := err.(ErrMergeUnrelatedHistories)
  1157. return ok
  1158. }
  1159. func (err ErrMergeUnrelatedHistories) Error() string {
  1160. return fmt.Sprintf("Merge UnrelatedHistories Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1161. }
  1162. // ErrRebaseConflicts represents an error if rebase fails with a conflict
  1163. type ErrRebaseConflicts struct {
  1164. Style MergeStyle
  1165. CommitSHA string
  1166. StdOut string
  1167. StdErr string
  1168. Err error
  1169. }
  1170. // IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.
  1171. func IsErrRebaseConflicts(err error) bool {
  1172. _, ok := err.(ErrRebaseConflicts)
  1173. return ok
  1174. }
  1175. func (err ErrRebaseConflicts) Error() string {
  1176. return fmt.Sprintf("Rebase Error: %v: Whilst Rebasing: %s\n%s\n%s", err.Err, err.CommitSHA, err.StdErr, err.StdOut)
  1177. }
  1178. // ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error
  1179. type ErrPullRequestHasMerged struct {
  1180. ID int64
  1181. IssueID int64
  1182. HeadRepoID int64
  1183. BaseRepoID int64
  1184. HeadBranch string
  1185. BaseBranch string
  1186. }
  1187. // IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.
  1188. func IsErrPullRequestHasMerged(err error) bool {
  1189. _, ok := err.(ErrPullRequestHasMerged)
  1190. return ok
  1191. }
  1192. // Error does pretty-printing :D
  1193. func (err ErrPullRequestHasMerged) Error() string {
  1194. 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]",
  1195. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1196. }
  1197. // _________ __
  1198. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  1199. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  1200. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  1201. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  1202. // \/ \/ \/ \/ \/
  1203. // ErrCommentNotExist represents a "CommentNotExist" kind of error.
  1204. type ErrCommentNotExist struct {
  1205. ID int64
  1206. IssueID int64
  1207. }
  1208. // IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
  1209. func IsErrCommentNotExist(err error) bool {
  1210. _, ok := err.(ErrCommentNotExist)
  1211. return ok
  1212. }
  1213. func (err ErrCommentNotExist) Error() string {
  1214. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  1215. }
  1216. // _________ __ __ .__
  1217. // / _____// |_ ____ ________ _ _______ _/ |_ ____ | |__
  1218. // \_____ \\ __\/ _ \\____ \ \/ \/ /\__ \\ __\/ ___\| | \
  1219. // / \| | ( <_> ) |_> > / / __ \| | \ \___| Y \
  1220. // /_______ /|__| \____/| __/ \/\_/ (____ /__| \___ >___| /
  1221. // \/ |__| \/ \/ \/
  1222. // ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.
  1223. type ErrStopwatchNotExist struct {
  1224. ID int64
  1225. }
  1226. // IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.
  1227. func IsErrStopwatchNotExist(err error) bool {
  1228. _, ok := err.(ErrStopwatchNotExist)
  1229. return ok
  1230. }
  1231. func (err ErrStopwatchNotExist) Error() string {
  1232. return fmt.Sprintf("stopwatch does not exist [id: %d]", err.ID)
  1233. }
  1234. // ___________ __ .______________.__
  1235. // \__ ___/___________ ____ | | __ ____ __| _/\__ ___/|__| _____ ____
  1236. // | | \_ __ \__ \ _/ ___\| |/ // __ \ / __ | | | | |/ \_/ __ \
  1237. // | | | | \// __ \\ \___| <\ ___// /_/ | | | | | Y Y \ ___/
  1238. // |____| |__| (____ /\___ >__|_ \\___ >____ | |____| |__|__|_| /\___ >
  1239. // \/ \/ \/ \/ \/ \/ \/
  1240. // ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.
  1241. type ErrTrackedTimeNotExist struct {
  1242. ID int64
  1243. }
  1244. // IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.
  1245. func IsErrTrackedTimeNotExist(err error) bool {
  1246. _, ok := err.(ErrTrackedTimeNotExist)
  1247. return ok
  1248. }
  1249. func (err ErrTrackedTimeNotExist) Error() string {
  1250. return fmt.Sprintf("tracked time does not exist [id: %d]", err.ID)
  1251. }
  1252. // .____ ___. .__
  1253. // | | _____ \_ |__ ____ | |
  1254. // | | \__ \ | __ \_/ __ \| |
  1255. // | |___ / __ \| \_\ \ ___/| |__
  1256. // |_______ (____ /___ /\___ >____/
  1257. // \/ \/ \/ \/
  1258. // ErrRepoLabelNotExist represents a "RepoLabelNotExist" kind of error.
  1259. type ErrRepoLabelNotExist struct {
  1260. LabelID int64
  1261. RepoID int64
  1262. }
  1263. // IsErrRepoLabelNotExist checks if an error is a RepoErrLabelNotExist.
  1264. func IsErrRepoLabelNotExist(err error) bool {
  1265. _, ok := err.(ErrRepoLabelNotExist)
  1266. return ok
  1267. }
  1268. func (err ErrRepoLabelNotExist) Error() string {
  1269. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  1270. }
  1271. // ErrOrgLabelNotExist represents a "OrgLabelNotExist" kind of error.
  1272. type ErrOrgLabelNotExist struct {
  1273. LabelID int64
  1274. OrgID int64
  1275. }
  1276. // IsErrOrgLabelNotExist checks if an error is a OrgErrLabelNotExist.
  1277. func IsErrOrgLabelNotExist(err error) bool {
  1278. _, ok := err.(ErrOrgLabelNotExist)
  1279. return ok
  1280. }
  1281. func (err ErrOrgLabelNotExist) Error() string {
  1282. return fmt.Sprintf("label does not exist [label_id: %d, org_id: %d]", err.LabelID, err.OrgID)
  1283. }
  1284. // ErrLabelNotExist represents a "LabelNotExist" kind of error.
  1285. type ErrLabelNotExist struct {
  1286. LabelID int64
  1287. }
  1288. // IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
  1289. func IsErrLabelNotExist(err error) bool {
  1290. _, ok := err.(ErrLabelNotExist)
  1291. return ok
  1292. }
  1293. func (err ErrLabelNotExist) Error() string {
  1294. return fmt.Sprintf("label does not exist [label_id: %d]", err.LabelID)
  1295. }
  1296. // __________ __ __
  1297. // \______ \_______ ____ |__| ____ _____/ |_ ______
  1298. // | ___/\_ __ \/ _ \ | |/ __ \_/ ___\ __\/ ___/
  1299. // | | | | \( <_> ) | \ ___/\ \___| | \___ \
  1300. // |____| |__| \____/\__| |\___ >\___ >__| /____ >
  1301. // \______| \/ \/ \/
  1302. // ErrProjectNotExist represents a "ProjectNotExist" kind of error.
  1303. type ErrProjectNotExist struct {
  1304. ID int64
  1305. RepoID int64
  1306. }
  1307. // IsErrProjectNotExist checks if an error is a ErrProjectNotExist
  1308. func IsErrProjectNotExist(err error) bool {
  1309. _, ok := err.(ErrProjectNotExist)
  1310. return ok
  1311. }
  1312. func (err ErrProjectNotExist) Error() string {
  1313. return fmt.Sprintf("projects does not exist [id: %d]", err.ID)
  1314. }
  1315. // ErrProjectBoardNotExist represents a "ProjectBoardNotExist" kind of error.
  1316. type ErrProjectBoardNotExist struct {
  1317. BoardID int64
  1318. }
  1319. // IsErrProjectBoardNotExist checks if an error is a ErrProjectBoardNotExist
  1320. func IsErrProjectBoardNotExist(err error) bool {
  1321. _, ok := err.(ErrProjectBoardNotExist)
  1322. return ok
  1323. }
  1324. func (err ErrProjectBoardNotExist) Error() string {
  1325. return fmt.Sprintf("project board does not exist [id: %d]", err.BoardID)
  1326. }
  1327. // _____ .__.__ __
  1328. // / \ |__| | ____ _______/ |_ ____ ____ ____
  1329. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  1330. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  1331. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  1332. // \/ \/ \/ \/ \/
  1333. // ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.
  1334. type ErrMilestoneNotExist struct {
  1335. ID int64
  1336. RepoID int64
  1337. Name string
  1338. }
  1339. // IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
  1340. func IsErrMilestoneNotExist(err error) bool {
  1341. _, ok := err.(ErrMilestoneNotExist)
  1342. return ok
  1343. }
  1344. func (err ErrMilestoneNotExist) Error() string {
  1345. if len(err.Name) > 0 {
  1346. return fmt.Sprintf("milestone does not exist [name: %s, repo_id: %d]", err.Name, err.RepoID)
  1347. }
  1348. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  1349. }
  1350. // _____ __ __ .__ __
  1351. // / _ \_/ |__/ |______ ____ | |__ _____ ____ _____/ |_
  1352. // / /_\ \ __\ __\__ \ _/ ___\| | \ / \_/ __ \ / \ __\
  1353. // / | \ | | | / __ \\ \___| Y \ Y Y \ ___/| | \ |
  1354. // \____|__ /__| |__| (____ /\___ >___| /__|_| /\___ >___| /__|
  1355. // \/ \/ \/ \/ \/ \/ \/
  1356. // ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.
  1357. type ErrAttachmentNotExist struct {
  1358. ID int64
  1359. UUID string
  1360. }
  1361. // IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.
  1362. func IsErrAttachmentNotExist(err error) bool {
  1363. _, ok := err.(ErrAttachmentNotExist)
  1364. return ok
  1365. }
  1366. func (err ErrAttachmentNotExist) Error() string {
  1367. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1368. }
  1369. // .____ .__ _________
  1370. // | | ____ ____ |__| ____ / _____/ ____ __ _________ ____ ____
  1371. // | | / _ \ / ___\| |/ \ \_____ \ / _ \| | \_ __ \_/ ___\/ __ \
  1372. // | |__( <_> ) /_/ > | | \ / ( <_> ) | /| | \/\ \__\ ___/
  1373. // |_______ \____/\___ /|__|___| / /_______ /\____/|____/ |__| \___ >___ >
  1374. // \/ /_____/ \/ \/ \/ \/
  1375. // ErrLoginSourceNotExist represents a "LoginSourceNotExist" kind of error.
  1376. type ErrLoginSourceNotExist struct {
  1377. ID int64
  1378. }
  1379. // IsErrLoginSourceNotExist checks if an error is a ErrLoginSourceNotExist.
  1380. func IsErrLoginSourceNotExist(err error) bool {
  1381. _, ok := err.(ErrLoginSourceNotExist)
  1382. return ok
  1383. }
  1384. func (err ErrLoginSourceNotExist) Error() string {
  1385. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  1386. }
  1387. // ErrLoginSourceAlreadyExist represents a "LoginSourceAlreadyExist" kind of error.
  1388. type ErrLoginSourceAlreadyExist struct {
  1389. Name string
  1390. }
  1391. // IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.
  1392. func IsErrLoginSourceAlreadyExist(err error) bool {
  1393. _, ok := err.(ErrLoginSourceAlreadyExist)
  1394. return ok
  1395. }
  1396. func (err ErrLoginSourceAlreadyExist) Error() string {
  1397. return fmt.Sprintf("login source already exists [name: %s]", err.Name)
  1398. }
  1399. // ErrLoginSourceInUse represents a "LoginSourceInUse" kind of error.
  1400. type ErrLoginSourceInUse struct {
  1401. ID int64
  1402. }
  1403. // IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.
  1404. func IsErrLoginSourceInUse(err error) bool {
  1405. _, ok := err.(ErrLoginSourceInUse)
  1406. return ok
  1407. }
  1408. func (err ErrLoginSourceInUse) Error() string {
  1409. return fmt.Sprintf("login source is still used by some users [id: %d]", err.ID)
  1410. }
  1411. // ___________
  1412. // \__ ___/___ _____ _____
  1413. // | |_/ __ \\__ \ / \
  1414. // | |\ ___/ / __ \| Y Y \
  1415. // |____| \___ >____ /__|_| /
  1416. // \/ \/ \/
  1417. // ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
  1418. type ErrTeamAlreadyExist struct {
  1419. OrgID int64
  1420. Name string
  1421. }
  1422. // IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
  1423. func IsErrTeamAlreadyExist(err error) bool {
  1424. _, ok := err.(ErrTeamAlreadyExist)
  1425. return ok
  1426. }
  1427. func (err ErrTeamAlreadyExist) Error() string {
  1428. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  1429. }
  1430. // ErrTeamNotExist represents a "TeamNotExist" error
  1431. type ErrTeamNotExist struct {
  1432. OrgID int64
  1433. TeamID int64
  1434. Name string
  1435. }
  1436. // IsErrTeamNotExist checks if an error is a ErrTeamNotExist.
  1437. func IsErrTeamNotExist(err error) bool {
  1438. _, ok := err.(ErrTeamNotExist)
  1439. return ok
  1440. }
  1441. func (err ErrTeamNotExist) Error() string {
  1442. return fmt.Sprintf("team does not exist [org_id %d, team_id %d, name: %s]", err.OrgID, err.TeamID, err.Name)
  1443. }
  1444. //
  1445. // Two-factor authentication
  1446. //
  1447. // ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication.
  1448. type ErrTwoFactorNotEnrolled struct {
  1449. UID int64
  1450. }
  1451. // IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled.
  1452. func IsErrTwoFactorNotEnrolled(err error) bool {
  1453. _, ok := err.(ErrTwoFactorNotEnrolled)
  1454. return ok
  1455. }
  1456. func (err ErrTwoFactorNotEnrolled) Error() string {
  1457. return fmt.Sprintf("user not enrolled in 2FA [uid: %d]", err.UID)
  1458. }
  1459. // ____ ___ .__ .___
  1460. // | | \______ | | _________ __| _/
  1461. // | | /\____ \| | / _ \__ \ / __ |
  1462. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  1463. // |______/ | __/|____/\____(____ /\____ |
  1464. // |__| \/ \/
  1465. //
  1466. // ErrUploadNotExist represents a "UploadNotExist" kind of error.
  1467. type ErrUploadNotExist struct {
  1468. ID int64
  1469. UUID string
  1470. }
  1471. // IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
  1472. func IsErrUploadNotExist(err error) bool {
  1473. _, ok := err.(ErrAttachmentNotExist)
  1474. return ok
  1475. }
  1476. func (err ErrUploadNotExist) Error() string {
  1477. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1478. }
  1479. // ___________ __ .__ .____ .__ ____ ___
  1480. // \_ _____/__ ____/ |_ ___________ ____ _____ | | | | ____ ____ |__| ____ | | \______ ___________
  1481. // | __)_\ \/ /\ __\/ __ \_ __ \/ \\__ \ | | | | / _ \ / ___\| |/ \ | | / ___// __ \_ __ \
  1482. // | \> < | | \ ___/| | \/ | \/ __ \| |__ | |__( <_> ) /_/ > | | \ | | /\___ \\ ___/| | \/
  1483. // /_______ /__/\_ \ |__| \___ >__| |___| (____ /____/ |_______ \____/\___ /|__|___| / |______//____ >\___ >__|
  1484. // \/ \/ \/ \/ \/ \/ /_____/ \/ \/ \/
  1485. // ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
  1486. type ErrExternalLoginUserAlreadyExist struct {
  1487. ExternalID string
  1488. UserID int64
  1489. LoginSourceID int64
  1490. }
  1491. // IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.
  1492. func IsErrExternalLoginUserAlreadyExist(err error) bool {
  1493. _, ok := err.(ErrExternalLoginUserAlreadyExist)
  1494. return ok
  1495. }
  1496. func (err ErrExternalLoginUserAlreadyExist) Error() string {
  1497. return fmt.Sprintf("external login user already exists [externalID: %s, userID: %d, loginSourceID: %d]", err.ExternalID, err.UserID, err.LoginSourceID)
  1498. }
  1499. // ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
  1500. type ErrExternalLoginUserNotExist struct {
  1501. UserID int64
  1502. LoginSourceID int64
  1503. }
  1504. // IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.
  1505. func IsErrExternalLoginUserNotExist(err error) bool {
  1506. _, ok := err.(ErrExternalLoginUserNotExist)
  1507. return ok
  1508. }
  1509. func (err ErrExternalLoginUserNotExist) Error() string {
  1510. return fmt.Sprintf("external login user link does not exists [userID: %d, loginSourceID: %d]", err.UserID, err.LoginSourceID)
  1511. }
  1512. // ____ ________________________________ .__ __ __ .__
  1513. // | | \_____ \_ _____/\______ \ ____ ____ |__| _______/ |_____________ _/ |_|__| ____ ____
  1514. // | | // ____/| __) | _// __ \ / ___\| |/ ___/\ __\_ __ \__ \\ __\ |/ _ \ / \
  1515. // | | // \| \ | | \ ___// /_/ > |\___ \ | | | | \// __ \| | | ( <_> ) | \
  1516. // |______/ \_______ \___ / |____|_ /\___ >___ /|__/____ > |__| |__| (____ /__| |__|\____/|___| /
  1517. // \/ \/ \/ \/_____/ \/ \/ \/
  1518. // ErrU2FRegistrationNotExist represents a "ErrU2FRegistrationNotExist" kind of error.
  1519. type ErrU2FRegistrationNotExist struct {
  1520. ID int64
  1521. }
  1522. func (err ErrU2FRegistrationNotExist) Error() string {
  1523. return fmt.Sprintf("U2F registration does not exist [id: %d]", err.ID)
  1524. }
  1525. // IsErrU2FRegistrationNotExist checks if an error is a ErrU2FRegistrationNotExist.
  1526. func IsErrU2FRegistrationNotExist(err error) bool {
  1527. _, ok := err.(ErrU2FRegistrationNotExist)
  1528. return ok
  1529. }
  1530. // .___ ________ .___ .__
  1531. // | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
  1532. // | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
  1533. // | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
  1534. // |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
  1535. // \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
  1536. // ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
  1537. type ErrDependencyExists struct {
  1538. IssueID int64
  1539. DependencyID int64
  1540. }
  1541. // IsErrDependencyExists checks if an error is a ErrDependencyExists.
  1542. func IsErrDependencyExists(err error) bool {
  1543. _, ok := err.(ErrDependencyExists)
  1544. return ok
  1545. }
  1546. func (err ErrDependencyExists) Error() string {
  1547. return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1548. }
  1549. // ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
  1550. type ErrDependencyNotExists struct {
  1551. IssueID int64
  1552. DependencyID int64
  1553. }
  1554. // IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
  1555. func IsErrDependencyNotExists(err error) bool {
  1556. _, ok := err.(ErrDependencyNotExists)
  1557. return ok
  1558. }
  1559. func (err ErrDependencyNotExists) Error() string {
  1560. return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1561. }
  1562. // ErrCircularDependency represents a "DependencyCircular" kind of error.
  1563. type ErrCircularDependency struct {
  1564. IssueID int64
  1565. DependencyID int64
  1566. }
  1567. // IsErrCircularDependency checks if an error is a ErrCircularDependency.
  1568. func IsErrCircularDependency(err error) bool {
  1569. _, ok := err.(ErrCircularDependency)
  1570. return ok
  1571. }
  1572. func (err ErrCircularDependency) Error() string {
  1573. return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1574. }
  1575. // ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
  1576. type ErrDependenciesLeft struct {
  1577. IssueID int64
  1578. }
  1579. // IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
  1580. func IsErrDependenciesLeft(err error) bool {
  1581. _, ok := err.(ErrDependenciesLeft)
  1582. return ok
  1583. }
  1584. func (err ErrDependenciesLeft) Error() string {
  1585. return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
  1586. }
  1587. // ErrUnknownDependencyType represents an error where an unknown dependency type was passed
  1588. type ErrUnknownDependencyType struct {
  1589. Type DependencyType
  1590. }
  1591. // IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
  1592. func IsErrUnknownDependencyType(err error) bool {
  1593. _, ok := err.(ErrUnknownDependencyType)
  1594. return ok
  1595. }
  1596. func (err ErrUnknownDependencyType) Error() string {
  1597. return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
  1598. }
  1599. // __________ .__
  1600. // \______ \ _______ _|__| ______ _ __
  1601. // | _// __ \ \/ / |/ __ \ \/ \/ /
  1602. // | | \ ___/\ /| \ ___/\ /
  1603. // |____|_ /\___ >\_/ |__|\___ >\/\_/
  1604. // \/ \/ \/
  1605. // ErrReviewNotExist represents a "ReviewNotExist" kind of error.
  1606. type ErrReviewNotExist struct {
  1607. ID int64
  1608. }
  1609. // IsErrReviewNotExist checks if an error is a ErrReviewNotExist.
  1610. func IsErrReviewNotExist(err error) bool {
  1611. _, ok := err.(ErrReviewNotExist)
  1612. return ok
  1613. }
  1614. func (err ErrReviewNotExist) Error() string {
  1615. return fmt.Sprintf("review does not exist [id: %d]", err.ID)
  1616. }
  1617. // ________ _____ __ .__
  1618. // \_____ \ / _ \ __ ___/ |_| |__
  1619. // / | \ / /_\ \| | \ __\ | \
  1620. // / | \/ | \ | /| | | Y \
  1621. // \_______ /\____|__ /____/ |__| |___| /
  1622. // \/ \/ \/
  1623. // ErrOAuthClientIDInvalid will be thrown if client id cannot be found
  1624. type ErrOAuthClientIDInvalid struct {
  1625. ClientID string
  1626. }
  1627. // IsErrOauthClientIDInvalid checks if an error is a ErrReviewNotExist.
  1628. func IsErrOauthClientIDInvalid(err error) bool {
  1629. _, ok := err.(ErrOAuthClientIDInvalid)
  1630. return ok
  1631. }
  1632. // Error returns the error message
  1633. func (err ErrOAuthClientIDInvalid) Error() string {
  1634. return fmt.Sprintf("Client ID invalid [Client ID: %s]", err.ClientID)
  1635. }
  1636. // ErrOAuthApplicationNotFound will be thrown if id cannot be found
  1637. type ErrOAuthApplicationNotFound struct {
  1638. ID int64
  1639. }
  1640. // IsErrOAuthApplicationNotFound checks if an error is a ErrReviewNotExist.
  1641. func IsErrOAuthApplicationNotFound(err error) bool {
  1642. _, ok := err.(ErrOAuthApplicationNotFound)
  1643. return ok
  1644. }
  1645. // Error returns the error message
  1646. func (err ErrOAuthApplicationNotFound) Error() string {
  1647. return fmt.Sprintf("OAuth application not found [ID: %d]", err.ID)
  1648. }