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

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