您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  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/models/perm"
  9. repo_model "code.gitea.io/gitea/models/repo"
  10. "code.gitea.io/gitea/modules/git"
  11. )
  12. // ErrNotExist represents a non-exist error.
  13. type ErrNotExist struct {
  14. ID int64
  15. }
  16. // IsErrNotExist checks if an error is an ErrNotExist
  17. func IsErrNotExist(err error) bool {
  18. _, ok := err.(ErrNotExist)
  19. return ok
  20. }
  21. func (err ErrNotExist) Error() string {
  22. return fmt.Sprintf("record does not exist [id: %d]", err.ID)
  23. }
  24. // ErrUserOwnRepos represents a "UserOwnRepos" kind of error.
  25. type ErrUserOwnRepos struct {
  26. UID int64
  27. }
  28. // IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.
  29. func IsErrUserOwnRepos(err error) bool {
  30. _, ok := err.(ErrUserOwnRepos)
  31. return ok
  32. }
  33. func (err ErrUserOwnRepos) Error() string {
  34. return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
  35. }
  36. // ErrUserHasOrgs represents a "UserHasOrgs" kind of error.
  37. type ErrUserHasOrgs struct {
  38. UID int64
  39. }
  40. // IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.
  41. func IsErrUserHasOrgs(err error) bool {
  42. _, ok := err.(ErrUserHasOrgs)
  43. return ok
  44. }
  45. func (err ErrUserHasOrgs) Error() string {
  46. return fmt.Sprintf("user still has membership of organizations [uid: %d]", err.UID)
  47. }
  48. // ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.
  49. type ErrUserNotAllowedCreateOrg struct{}
  50. // IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.
  51. func IsErrUserNotAllowedCreateOrg(err error) bool {
  52. _, ok := err.(ErrUserNotAllowedCreateOrg)
  53. return ok
  54. }
  55. func (err ErrUserNotAllowedCreateOrg) Error() string {
  56. return "user is not allowed to create organizations"
  57. }
  58. // ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.
  59. type ErrReachLimitOfRepo struct {
  60. Limit int
  61. }
  62. // IsErrReachLimitOfRepo checks if an error is a ErrReachLimitOfRepo.
  63. func IsErrReachLimitOfRepo(err error) bool {
  64. _, ok := err.(ErrReachLimitOfRepo)
  65. return ok
  66. }
  67. func (err ErrReachLimitOfRepo) Error() string {
  68. return fmt.Sprintf("user has reached maximum limit of repositories [limit: %d]", err.Limit)
  69. }
  70. // __ __.__ __ .__
  71. // / \ / \__| | _|__|
  72. // \ \/\/ / | |/ / |
  73. // \ /| | <| |
  74. // \__/\ / |__|__|_ \__|
  75. // \/ \/
  76. // ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.
  77. type ErrWikiAlreadyExist struct {
  78. Title string
  79. }
  80. // IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
  81. func IsErrWikiAlreadyExist(err error) bool {
  82. _, ok := err.(ErrWikiAlreadyExist)
  83. return ok
  84. }
  85. func (err ErrWikiAlreadyExist) Error() string {
  86. return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
  87. }
  88. // ErrWikiReservedName represents a reserved name error.
  89. type ErrWikiReservedName struct {
  90. Title string
  91. }
  92. // IsErrWikiReservedName checks if an error is an ErrWikiReservedName.
  93. func IsErrWikiReservedName(err error) bool {
  94. _, ok := err.(ErrWikiReservedName)
  95. return ok
  96. }
  97. func (err ErrWikiReservedName) Error() string {
  98. return fmt.Sprintf("wiki title is reserved: %s", err.Title)
  99. }
  100. // ErrWikiInvalidFileName represents an invalid wiki file name.
  101. type ErrWikiInvalidFileName struct {
  102. FileName string
  103. }
  104. // IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.
  105. func IsErrWikiInvalidFileName(err error) bool {
  106. _, ok := err.(ErrWikiInvalidFileName)
  107. return ok
  108. }
  109. func (err ErrWikiInvalidFileName) Error() string {
  110. return fmt.Sprintf("Invalid wiki filename: %s", err.FileName)
  111. }
  112. // _____ ___________ __
  113. // / _ \ ____ ____ ____ ______ _____\__ ___/___ | | __ ____ ____
  114. // / /_\ \_/ ___\/ ___\/ __ \ / ___// ___/ | | / _ \| |/ // __ \ / \
  115. // / | \ \__\ \__\ ___/ \___ \ \___ \ | |( <_> ) <\ ___/| | \
  116. // \____|__ /\___ >___ >___ >____ >____ > |____| \____/|__|_ \\___ >___| /
  117. // \/ \/ \/ \/ \/ \/ \/ \/ \/
  118. // ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.
  119. type ErrAccessTokenNotExist struct {
  120. Token string
  121. }
  122. // IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.
  123. func IsErrAccessTokenNotExist(err error) bool {
  124. _, ok := err.(ErrAccessTokenNotExist)
  125. return ok
  126. }
  127. func (err ErrAccessTokenNotExist) Error() string {
  128. return fmt.Sprintf("access token does not exist [sha: %s]", err.Token)
  129. }
  130. // ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.
  131. type ErrAccessTokenEmpty struct{}
  132. // IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.
  133. func IsErrAccessTokenEmpty(err error) bool {
  134. _, ok := err.(ErrAccessTokenEmpty)
  135. return ok
  136. }
  137. func (err ErrAccessTokenEmpty) Error() string {
  138. return "access token is empty"
  139. }
  140. // ________ .__ __ .__
  141. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  142. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  143. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  144. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  145. // \/ /_____/ \/ \/ \/ \/ \/
  146. // ErrOrgNotExist represents a "OrgNotExist" kind of error.
  147. type ErrOrgNotExist struct {
  148. ID int64
  149. Name string
  150. }
  151. // IsErrOrgNotExist checks if an error is a ErrOrgNotExist.
  152. func IsErrOrgNotExist(err error) bool {
  153. _, ok := err.(ErrOrgNotExist)
  154. return ok
  155. }
  156. func (err ErrOrgNotExist) Error() string {
  157. return fmt.Sprintf("org does not exist [id: %d, name: %s]", err.ID, err.Name)
  158. }
  159. // ErrLastOrgOwner represents a "LastOrgOwner" kind of error.
  160. type ErrLastOrgOwner struct {
  161. UID int64
  162. }
  163. // IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.
  164. func IsErrLastOrgOwner(err error) bool {
  165. _, ok := err.(ErrLastOrgOwner)
  166. return ok
  167. }
  168. func (err ErrLastOrgOwner) Error() string {
  169. return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
  170. }
  171. //.____ ____________________
  172. //| | \_ _____/ _____/
  173. //| | | __) \_____ \
  174. //| |___| \ / \
  175. //|_______ \___ / /_______ /
  176. // \/ \/ \/
  177. // ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
  178. type ErrLFSLockNotExist struct {
  179. ID int64
  180. RepoID int64
  181. Path string
  182. }
  183. // IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.
  184. func IsErrLFSLockNotExist(err error) bool {
  185. _, ok := err.(ErrLFSLockNotExist)
  186. return ok
  187. }
  188. func (err ErrLFSLockNotExist) Error() string {
  189. return fmt.Sprintf("lfs lock does not exist [id: %d, rid: %d, path: %s]", err.ID, err.RepoID, err.Path)
  190. }
  191. // ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.
  192. type ErrLFSUnauthorizedAction struct {
  193. RepoID int64
  194. UserName string
  195. Mode perm.AccessMode
  196. }
  197. // IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.
  198. func IsErrLFSUnauthorizedAction(err error) bool {
  199. _, ok := err.(ErrLFSUnauthorizedAction)
  200. return ok
  201. }
  202. func (err ErrLFSUnauthorizedAction) Error() string {
  203. if err.Mode == perm.AccessModeWrite {
  204. return fmt.Sprintf("User %s doesn't have write access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  205. }
  206. return fmt.Sprintf("User %s doesn't have read access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  207. }
  208. // ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
  209. type ErrLFSLockAlreadyExist struct {
  210. RepoID int64
  211. Path string
  212. }
  213. // IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.
  214. func IsErrLFSLockAlreadyExist(err error) bool {
  215. _, ok := err.(ErrLFSLockAlreadyExist)
  216. return ok
  217. }
  218. func (err ErrLFSLockAlreadyExist) Error() string {
  219. return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
  220. }
  221. // ErrLFSFileLocked represents a "LFSFileLocked" kind of error.
  222. type ErrLFSFileLocked struct {
  223. RepoID int64
  224. Path string
  225. UserName string
  226. }
  227. // IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.
  228. func IsErrLFSFileLocked(err error) bool {
  229. _, ok := err.(ErrLFSFileLocked)
  230. return ok
  231. }
  232. func (err ErrLFSFileLocked) Error() string {
  233. return fmt.Sprintf("File is lfs locked [repo: %d, locked by: %s, path: %s]", err.RepoID, err.UserName, err.Path)
  234. }
  235. // ErrNoPendingRepoTransfer is an error type for repositories without a pending
  236. // transfer request
  237. type ErrNoPendingRepoTransfer struct {
  238. RepoID int64
  239. }
  240. func (e ErrNoPendingRepoTransfer) Error() string {
  241. return fmt.Sprintf("repository doesn't have a pending transfer [repo_id: %d]", e.RepoID)
  242. }
  243. // IsErrNoPendingTransfer is an error type when a repository has no pending
  244. // transfers
  245. func IsErrNoPendingTransfer(err error) bool {
  246. _, ok := err.(ErrNoPendingRepoTransfer)
  247. return ok
  248. }
  249. // ErrRepoTransferInProgress represents the state of a repository that has an
  250. // ongoing transfer
  251. type ErrRepoTransferInProgress struct {
  252. Uname string
  253. Name string
  254. }
  255. // IsErrRepoTransferInProgress checks if an error is a ErrRepoTransferInProgress.
  256. func IsErrRepoTransferInProgress(err error) bool {
  257. _, ok := err.(ErrRepoTransferInProgress)
  258. return ok
  259. }
  260. func (err ErrRepoTransferInProgress) Error() string {
  261. return fmt.Sprintf("repository is already being transferred [uname: %s, name: %s]", err.Uname, err.Name)
  262. }
  263. // ErrRepoAlreadyExist represents a "RepoAlreadyExist" kind of error.
  264. type ErrRepoAlreadyExist struct {
  265. Uname string
  266. Name string
  267. }
  268. // IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.
  269. func IsErrRepoAlreadyExist(err error) bool {
  270. _, ok := err.(ErrRepoAlreadyExist)
  271. return ok
  272. }
  273. func (err ErrRepoAlreadyExist) Error() string {
  274. return fmt.Sprintf("repository already exists [uname: %s, name: %s]", err.Uname, err.Name)
  275. }
  276. // ErrRepoFilesAlreadyExist represents a "RepoFilesAlreadyExist" kind of error.
  277. type ErrRepoFilesAlreadyExist struct {
  278. Uname string
  279. Name string
  280. }
  281. // IsErrRepoFilesAlreadyExist checks if an error is a ErrRepoAlreadyExist.
  282. func IsErrRepoFilesAlreadyExist(err error) bool {
  283. _, ok := err.(ErrRepoFilesAlreadyExist)
  284. return ok
  285. }
  286. func (err ErrRepoFilesAlreadyExist) Error() string {
  287. return fmt.Sprintf("repository files already exist [uname: %s, name: %s]", err.Uname, err.Name)
  288. }
  289. // ErrForkAlreadyExist represents a "ForkAlreadyExist" kind of error.
  290. type ErrForkAlreadyExist struct {
  291. Uname string
  292. RepoName string
  293. ForkName string
  294. }
  295. // IsErrForkAlreadyExist checks if an error is an ErrForkAlreadyExist.
  296. func IsErrForkAlreadyExist(err error) bool {
  297. _, ok := err.(ErrForkAlreadyExist)
  298. return ok
  299. }
  300. func (err ErrForkAlreadyExist) Error() string {
  301. return fmt.Sprintf("repository is already forked by user [uname: %s, repo path: %s, fork path: %s]", err.Uname, err.RepoName, err.ForkName)
  302. }
  303. // ErrRepoRedirectNotExist represents a "RepoRedirectNotExist" kind of error.
  304. type ErrRepoRedirectNotExist struct {
  305. OwnerID int64
  306. RepoName string
  307. }
  308. // IsErrRepoRedirectNotExist check if an error is an ErrRepoRedirectNotExist.
  309. func IsErrRepoRedirectNotExist(err error) bool {
  310. _, ok := err.(ErrRepoRedirectNotExist)
  311. return ok
  312. }
  313. func (err ErrRepoRedirectNotExist) Error() string {
  314. return fmt.Sprintf("repository redirect does not exist [uid: %d, name: %s]", err.OwnerID, err.RepoName)
  315. }
  316. // ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.
  317. type ErrInvalidCloneAddr struct {
  318. Host string
  319. IsURLError bool
  320. IsInvalidPath bool
  321. IsProtocolInvalid bool
  322. IsPermissionDenied bool
  323. LocalPath bool
  324. NotResolvedIP bool
  325. }
  326. // IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
  327. func IsErrInvalidCloneAddr(err error) bool {
  328. _, ok := err.(*ErrInvalidCloneAddr)
  329. return ok
  330. }
  331. func (err *ErrInvalidCloneAddr) Error() string {
  332. if err.NotResolvedIP {
  333. return fmt.Sprintf("migration/cloning from '%s' is not allowed: unknown hostname", err.Host)
  334. }
  335. if err.IsInvalidPath {
  336. return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided path is invalid", err.Host)
  337. }
  338. if err.IsProtocolInvalid {
  339. return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided url protocol is not allowed", err.Host)
  340. }
  341. if err.IsPermissionDenied {
  342. return fmt.Sprintf("migration/cloning from '%s' is not allowed.", err.Host)
  343. }
  344. if err.IsURLError {
  345. return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided url is invalid", err.Host)
  346. }
  347. return fmt.Sprintf("migration/cloning from '%s' is not allowed", err.Host)
  348. }
  349. // ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.
  350. type ErrUpdateTaskNotExist struct {
  351. UUID string
  352. }
  353. // IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.
  354. func IsErrUpdateTaskNotExist(err error) bool {
  355. _, ok := err.(ErrUpdateTaskNotExist)
  356. return ok
  357. }
  358. func (err ErrUpdateTaskNotExist) Error() string {
  359. return fmt.Sprintf("update task does not exist [uuid: %s]", err.UUID)
  360. }
  361. // ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.
  362. type ErrReleaseAlreadyExist struct {
  363. TagName string
  364. }
  365. // IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.
  366. func IsErrReleaseAlreadyExist(err error) bool {
  367. _, ok := err.(ErrReleaseAlreadyExist)
  368. return ok
  369. }
  370. func (err ErrReleaseAlreadyExist) Error() string {
  371. return fmt.Sprintf("release tag already exist [tag_name: %s]", err.TagName)
  372. }
  373. // ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.
  374. type ErrReleaseNotExist struct {
  375. ID int64
  376. TagName string
  377. }
  378. // IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.
  379. func IsErrReleaseNotExist(err error) bool {
  380. _, ok := err.(ErrReleaseNotExist)
  381. return ok
  382. }
  383. func (err ErrReleaseNotExist) Error() string {
  384. return fmt.Sprintf("release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
  385. }
  386. // ErrInvalidTagName represents a "InvalidTagName" kind of error.
  387. type ErrInvalidTagName struct {
  388. TagName string
  389. }
  390. // IsErrInvalidTagName checks if an error is a ErrInvalidTagName.
  391. func IsErrInvalidTagName(err error) bool {
  392. _, ok := err.(ErrInvalidTagName)
  393. return ok
  394. }
  395. func (err ErrInvalidTagName) Error() string {
  396. return fmt.Sprintf("release tag name is not valid [tag_name: %s]", err.TagName)
  397. }
  398. // ErrProtectedTagName represents a "ProtectedTagName" kind of error.
  399. type ErrProtectedTagName struct {
  400. TagName string
  401. }
  402. // IsErrProtectedTagName checks if an error is a ErrProtectedTagName.
  403. func IsErrProtectedTagName(err error) bool {
  404. _, ok := err.(ErrProtectedTagName)
  405. return ok
  406. }
  407. func (err ErrProtectedTagName) Error() string {
  408. return fmt.Sprintf("release tag name is protected [tag_name: %s]", err.TagName)
  409. }
  410. // ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.
  411. type ErrRepoFileAlreadyExists struct {
  412. Path string
  413. }
  414. // IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.
  415. func IsErrRepoFileAlreadyExists(err error) bool {
  416. _, ok := err.(ErrRepoFileAlreadyExists)
  417. return ok
  418. }
  419. func (err ErrRepoFileAlreadyExists) Error() string {
  420. return fmt.Sprintf("repository file already exists [path: %s]", err.Path)
  421. }
  422. // ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.
  423. type ErrRepoFileDoesNotExist struct {
  424. Path string
  425. Name string
  426. }
  427. // IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.
  428. func IsErrRepoFileDoesNotExist(err error) bool {
  429. _, ok := err.(ErrRepoFileDoesNotExist)
  430. return ok
  431. }
  432. func (err ErrRepoFileDoesNotExist) Error() string {
  433. return fmt.Sprintf("repository file does not exist [path: %s]", err.Path)
  434. }
  435. // ErrFilenameInvalid represents a "FilenameInvalid" kind of error.
  436. type ErrFilenameInvalid struct {
  437. Path string
  438. }
  439. // IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.
  440. func IsErrFilenameInvalid(err error) bool {
  441. _, ok := err.(ErrFilenameInvalid)
  442. return ok
  443. }
  444. func (err ErrFilenameInvalid) Error() string {
  445. return fmt.Sprintf("path contains a malformed path component [path: %s]", err.Path)
  446. }
  447. // ErrUserCannotCommit represents "UserCannotCommit" kind of error.
  448. type ErrUserCannotCommit struct {
  449. UserName string
  450. }
  451. // IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.
  452. func IsErrUserCannotCommit(err error) bool {
  453. _, ok := err.(ErrUserCannotCommit)
  454. return ok
  455. }
  456. func (err ErrUserCannotCommit) Error() string {
  457. return fmt.Sprintf("user cannot commit to repo [user: %s]", err.UserName)
  458. }
  459. // ErrFilePathInvalid represents a "FilePathInvalid" kind of error.
  460. type ErrFilePathInvalid struct {
  461. Message string
  462. Path string
  463. Name string
  464. Type git.EntryMode
  465. }
  466. // IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.
  467. func IsErrFilePathInvalid(err error) bool {
  468. _, ok := err.(ErrFilePathInvalid)
  469. return ok
  470. }
  471. func (err ErrFilePathInvalid) Error() string {
  472. if err.Message != "" {
  473. return err.Message
  474. }
  475. return fmt.Sprintf("path is invalid [path: %s]", err.Path)
  476. }
  477. // ErrFilePathProtected represents a "FilePathProtected" kind of error.
  478. type ErrFilePathProtected struct {
  479. Message string
  480. Path string
  481. }
  482. // IsErrFilePathProtected checks if an error is an ErrFilePathProtected.
  483. func IsErrFilePathProtected(err error) bool {
  484. _, ok := err.(ErrFilePathProtected)
  485. return ok
  486. }
  487. func (err ErrFilePathProtected) Error() string {
  488. if err.Message != "" {
  489. return err.Message
  490. }
  491. return fmt.Sprintf("path is protected and can not be changed [path: %s]", err.Path)
  492. }
  493. // ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo.
  494. type ErrUserDoesNotHaveAccessToRepo struct {
  495. UserID int64
  496. RepoName string
  497. }
  498. // IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExists.
  499. func IsErrUserDoesNotHaveAccessToRepo(err error) bool {
  500. _, ok := err.(ErrUserDoesNotHaveAccessToRepo)
  501. return ok
  502. }
  503. func (err ErrUserDoesNotHaveAccessToRepo) Error() string {
  504. return fmt.Sprintf("user doesn't have access to repo [user_id: %d, repo_name: %s]", err.UserID, err.RepoName)
  505. }
  506. // __________ .__
  507. // \______ \____________ ____ ____ | |__
  508. // | | _/\_ __ \__ \ / \_/ ___\| | \
  509. // | | \ | | \// __ \| | \ \___| Y \
  510. // |______ / |__| (____ /___| /\___ >___| /
  511. // \/ \/ \/ \/ \/
  512. // ErrBranchDoesNotExist represents an error that branch with such name does not exist.
  513. type ErrBranchDoesNotExist struct {
  514. BranchName string
  515. }
  516. // IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.
  517. func IsErrBranchDoesNotExist(err error) bool {
  518. _, ok := err.(ErrBranchDoesNotExist)
  519. return ok
  520. }
  521. func (err ErrBranchDoesNotExist) Error() string {
  522. return fmt.Sprintf("branch does not exist [name: %s]", err.BranchName)
  523. }
  524. // ErrBranchAlreadyExists represents an error that branch with such name already exists.
  525. type ErrBranchAlreadyExists struct {
  526. BranchName string
  527. }
  528. // IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
  529. func IsErrBranchAlreadyExists(err error) bool {
  530. _, ok := err.(ErrBranchAlreadyExists)
  531. return ok
  532. }
  533. func (err ErrBranchAlreadyExists) Error() string {
  534. return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
  535. }
  536. // ErrBranchNameConflict represents an error that branch name conflicts with other branch.
  537. type ErrBranchNameConflict struct {
  538. BranchName string
  539. }
  540. // IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
  541. func IsErrBranchNameConflict(err error) bool {
  542. _, ok := err.(ErrBranchNameConflict)
  543. return ok
  544. }
  545. func (err ErrBranchNameConflict) Error() string {
  546. return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
  547. }
  548. // ErrBranchesEqual represents an error that branch name conflicts with other branch.
  549. type ErrBranchesEqual struct {
  550. BaseBranchName string
  551. HeadBranchName string
  552. }
  553. // IsErrBranchesEqual checks if an error is an ErrBranchesEqual.
  554. func IsErrBranchesEqual(err error) bool {
  555. _, ok := err.(ErrBranchesEqual)
  556. return ok
  557. }
  558. func (err ErrBranchesEqual) Error() string {
  559. return fmt.Sprintf("branches are equal [head: %sm base: %s]", err.HeadBranchName, err.BaseBranchName)
  560. }
  561. // ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
  562. type ErrNotAllowedToMerge struct {
  563. Reason string
  564. }
  565. // IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
  566. func IsErrNotAllowedToMerge(err error) bool {
  567. _, ok := err.(ErrNotAllowedToMerge)
  568. return ok
  569. }
  570. func (err ErrNotAllowedToMerge) Error() string {
  571. return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
  572. }
  573. // ErrTagAlreadyExists represents an error that tag with such name already exists.
  574. type ErrTagAlreadyExists struct {
  575. TagName string
  576. }
  577. // IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
  578. func IsErrTagAlreadyExists(err error) bool {
  579. _, ok := err.(ErrTagAlreadyExists)
  580. return ok
  581. }
  582. func (err ErrTagAlreadyExists) Error() string {
  583. return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
  584. }
  585. // ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.
  586. type ErrSHADoesNotMatch struct {
  587. Path string
  588. GivenSHA string
  589. CurrentSHA string
  590. }
  591. // IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.
  592. func IsErrSHADoesNotMatch(err error) bool {
  593. _, ok := err.(ErrSHADoesNotMatch)
  594. return ok
  595. }
  596. func (err ErrSHADoesNotMatch) Error() string {
  597. return fmt.Sprintf("sha does not match [given: %s, expected: %s]", err.GivenSHA, err.CurrentSHA)
  598. }
  599. // ErrSHANotFound represents a "SHADoesNotMatch" kind of error.
  600. type ErrSHANotFound struct {
  601. SHA string
  602. }
  603. // IsErrSHANotFound checks if an error is a ErrSHANotFound.
  604. func IsErrSHANotFound(err error) bool {
  605. _, ok := err.(ErrSHANotFound)
  606. return ok
  607. }
  608. func (err ErrSHANotFound) Error() string {
  609. return fmt.Sprintf("sha not found [%s]", err.SHA)
  610. }
  611. // ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.
  612. type ErrCommitIDDoesNotMatch struct {
  613. GivenCommitID string
  614. CurrentCommitID string
  615. }
  616. // IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.
  617. func IsErrCommitIDDoesNotMatch(err error) bool {
  618. _, ok := err.(ErrCommitIDDoesNotMatch)
  619. return ok
  620. }
  621. func (err ErrCommitIDDoesNotMatch) Error() string {
  622. return fmt.Sprintf("file CommitID does not match [given: %s, expected: %s]", err.GivenCommitID, err.CurrentCommitID)
  623. }
  624. // ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.
  625. type ErrSHAOrCommitIDNotProvided struct{}
  626. // IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.
  627. func IsErrSHAOrCommitIDNotProvided(err error) bool {
  628. _, ok := err.(ErrSHAOrCommitIDNotProvided)
  629. return ok
  630. }
  631. func (err ErrSHAOrCommitIDNotProvided) Error() string {
  632. return "a SHA or commit ID must be proved when updating a file"
  633. }
  634. // .___
  635. // | | ______ ________ __ ____
  636. // | |/ ___// ___/ | \_/ __ \
  637. // | |\___ \ \___ \| | /\ ___/
  638. // |___/____ >____ >____/ \___ >
  639. // \/ \/ \/
  640. // ErrIssueNotExist represents a "IssueNotExist" kind of error.
  641. type ErrIssueNotExist struct {
  642. ID int64
  643. RepoID int64
  644. Index int64
  645. }
  646. // IsErrIssueNotExist checks if an error is a ErrIssueNotExist.
  647. func IsErrIssueNotExist(err error) bool {
  648. _, ok := err.(ErrIssueNotExist)
  649. return ok
  650. }
  651. func (err ErrIssueNotExist) Error() string {
  652. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  653. }
  654. // ErrIssueIsClosed represents a "IssueIsClosed" kind of error.
  655. type ErrIssueIsClosed struct {
  656. ID int64
  657. RepoID int64
  658. Index int64
  659. }
  660. // IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.
  661. func IsErrIssueIsClosed(err error) bool {
  662. _, ok := err.(ErrIssueIsClosed)
  663. return ok
  664. }
  665. func (err ErrIssueIsClosed) Error() string {
  666. return fmt.Sprintf("issue is closed [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  667. }
  668. // ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.
  669. type ErrIssueLabelTemplateLoad struct {
  670. TemplateFile string
  671. OriginalError error
  672. }
  673. // IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.
  674. func IsErrIssueLabelTemplateLoad(err error) bool {
  675. _, ok := err.(ErrIssueLabelTemplateLoad)
  676. return ok
  677. }
  678. func (err ErrIssueLabelTemplateLoad) Error() string {
  679. return fmt.Sprintf("Failed to load label template file '%s': %v", err.TemplateFile, err.OriginalError)
  680. }
  681. // ErrNewIssueInsert is used when the INSERT statement in newIssue fails
  682. type ErrNewIssueInsert struct {
  683. OriginalError error
  684. }
  685. // IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.
  686. func IsErrNewIssueInsert(err error) bool {
  687. _, ok := err.(ErrNewIssueInsert)
  688. return ok
  689. }
  690. func (err ErrNewIssueInsert) Error() string {
  691. return err.OriginalError.Error()
  692. }
  693. // ErrIssueWasClosed is used when close a closed issue
  694. type ErrIssueWasClosed struct {
  695. ID int64
  696. Index int64
  697. }
  698. // IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.
  699. func IsErrIssueWasClosed(err error) bool {
  700. _, ok := err.(ErrIssueWasClosed)
  701. return ok
  702. }
  703. func (err ErrIssueWasClosed) Error() string {
  704. return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index)
  705. }
  706. // ErrPullWasClosed is used close a closed pull request
  707. type ErrPullWasClosed struct {
  708. ID int64
  709. Index int64
  710. }
  711. // IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed.
  712. func IsErrPullWasClosed(err error) bool {
  713. _, ok := err.(ErrPullWasClosed)
  714. return ok
  715. }
  716. func (err ErrPullWasClosed) Error() string {
  717. return fmt.Sprintf("Pull request [%d] %d was already closed", err.ID, err.Index)
  718. }
  719. // ErrForbiddenIssueReaction is used when a forbidden reaction was try to created
  720. type ErrForbiddenIssueReaction struct {
  721. Reaction string
  722. }
  723. // IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.
  724. func IsErrForbiddenIssueReaction(err error) bool {
  725. _, ok := err.(ErrForbiddenIssueReaction)
  726. return ok
  727. }
  728. func (err ErrForbiddenIssueReaction) Error() string {
  729. return fmt.Sprintf("'%s' is not an allowed reaction", err.Reaction)
  730. }
  731. // ErrReactionAlreadyExist is used when a existing reaction was try to created
  732. type ErrReactionAlreadyExist struct {
  733. Reaction string
  734. }
  735. // IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist.
  736. func IsErrReactionAlreadyExist(err error) bool {
  737. _, ok := err.(ErrReactionAlreadyExist)
  738. return ok
  739. }
  740. func (err ErrReactionAlreadyExist) Error() string {
  741. return fmt.Sprintf("reaction '%s' already exists", err.Reaction)
  742. }
  743. // __________ .__ .__ __________ __
  744. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  745. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  746. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  747. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  748. // \/ \/ |__| \/ \/
  749. // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
  750. type ErrPullRequestNotExist struct {
  751. ID int64
  752. IssueID int64
  753. HeadRepoID int64
  754. BaseRepoID int64
  755. HeadBranch string
  756. BaseBranch string
  757. }
  758. // IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
  759. func IsErrPullRequestNotExist(err error) bool {
  760. _, ok := err.(ErrPullRequestNotExist)
  761. return ok
  762. }
  763. func (err ErrPullRequestNotExist) Error() string {
  764. 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]",
  765. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  766. }
  767. // ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
  768. type ErrPullRequestAlreadyExists struct {
  769. ID int64
  770. IssueID int64
  771. HeadRepoID int64
  772. BaseRepoID int64
  773. HeadBranch string
  774. BaseBranch string
  775. }
  776. // IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
  777. func IsErrPullRequestAlreadyExists(err error) bool {
  778. _, ok := err.(ErrPullRequestAlreadyExists)
  779. return ok
  780. }
  781. // Error does pretty-printing :D
  782. func (err ErrPullRequestAlreadyExists) Error() string {
  783. 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]",
  784. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  785. }
  786. // ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error
  787. type ErrPullRequestHeadRepoMissing struct {
  788. ID int64
  789. HeadRepoID int64
  790. }
  791. // IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.
  792. func IsErrErrPullRequestHeadRepoMissing(err error) bool {
  793. _, ok := err.(ErrPullRequestHeadRepoMissing)
  794. return ok
  795. }
  796. // Error does pretty-printing :D
  797. func (err ErrPullRequestHeadRepoMissing) Error() string {
  798. return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]",
  799. err.ID, err.HeadRepoID)
  800. }
  801. // ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
  802. type ErrInvalidMergeStyle struct {
  803. ID int64
  804. Style repo_model.MergeStyle
  805. }
  806. // IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.
  807. func IsErrInvalidMergeStyle(err error) bool {
  808. _, ok := err.(ErrInvalidMergeStyle)
  809. return ok
  810. }
  811. func (err ErrInvalidMergeStyle) Error() string {
  812. return fmt.Sprintf("merge strategy is not allowed or is invalid [repo_id: %d, strategy: %s]",
  813. err.ID, err.Style)
  814. }
  815. // ErrMergeConflicts represents an error if merging fails with a conflict
  816. type ErrMergeConflicts struct {
  817. Style repo_model.MergeStyle
  818. StdOut string
  819. StdErr string
  820. Err error
  821. }
  822. // IsErrMergeConflicts checks if an error is a ErrMergeConflicts.
  823. func IsErrMergeConflicts(err error) bool {
  824. _, ok := err.(ErrMergeConflicts)
  825. return ok
  826. }
  827. func (err ErrMergeConflicts) Error() string {
  828. return fmt.Sprintf("Merge Conflict Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  829. }
  830. // ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories
  831. type ErrMergeUnrelatedHistories struct {
  832. Style repo_model.MergeStyle
  833. StdOut string
  834. StdErr string
  835. Err error
  836. }
  837. // IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.
  838. func IsErrMergeUnrelatedHistories(err error) bool {
  839. _, ok := err.(ErrMergeUnrelatedHistories)
  840. return ok
  841. }
  842. func (err ErrMergeUnrelatedHistories) Error() string {
  843. return fmt.Sprintf("Merge UnrelatedHistories Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  844. }
  845. // ErrRebaseConflicts represents an error if rebase fails with a conflict
  846. type ErrRebaseConflicts struct {
  847. Style repo_model.MergeStyle
  848. CommitSHA string
  849. StdOut string
  850. StdErr string
  851. Err error
  852. }
  853. // IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.
  854. func IsErrRebaseConflicts(err error) bool {
  855. _, ok := err.(ErrRebaseConflicts)
  856. return ok
  857. }
  858. func (err ErrRebaseConflicts) Error() string {
  859. return fmt.Sprintf("Rebase Error: %v: Whilst Rebasing: %s\n%s\n%s", err.Err, err.CommitSHA, err.StdErr, err.StdOut)
  860. }
  861. // ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error
  862. type ErrPullRequestHasMerged struct {
  863. ID int64
  864. IssueID int64
  865. HeadRepoID int64
  866. BaseRepoID int64
  867. HeadBranch string
  868. BaseBranch string
  869. }
  870. // IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.
  871. func IsErrPullRequestHasMerged(err error) bool {
  872. _, ok := err.(ErrPullRequestHasMerged)
  873. return ok
  874. }
  875. // Error does pretty-printing :D
  876. func (err ErrPullRequestHasMerged) Error() string {
  877. 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]",
  878. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  879. }
  880. // _________ __
  881. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  882. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  883. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  884. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  885. // \/ \/ \/ \/ \/
  886. // ErrCommentNotExist represents a "CommentNotExist" kind of error.
  887. type ErrCommentNotExist struct {
  888. ID int64
  889. IssueID int64
  890. }
  891. // IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
  892. func IsErrCommentNotExist(err error) bool {
  893. _, ok := err.(ErrCommentNotExist)
  894. return ok
  895. }
  896. func (err ErrCommentNotExist) Error() string {
  897. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  898. }
  899. // _________ __ __ .__
  900. // / _____// |_ ____ ________ _ _______ _/ |_ ____ | |__
  901. // \_____ \\ __\/ _ \\____ \ \/ \/ /\__ \\ __\/ ___\| | \
  902. // / \| | ( <_> ) |_> > / / __ \| | \ \___| Y \
  903. // /_______ /|__| \____/| __/ \/\_/ (____ /__| \___ >___| /
  904. // \/ |__| \/ \/ \/
  905. // ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.
  906. type ErrStopwatchNotExist struct {
  907. ID int64
  908. }
  909. // IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.
  910. func IsErrStopwatchNotExist(err error) bool {
  911. _, ok := err.(ErrStopwatchNotExist)
  912. return ok
  913. }
  914. func (err ErrStopwatchNotExist) Error() string {
  915. return fmt.Sprintf("stopwatch does not exist [id: %d]", err.ID)
  916. }
  917. // ___________ __ .______________.__
  918. // \__ ___/___________ ____ | | __ ____ __| _/\__ ___/|__| _____ ____
  919. // | | \_ __ \__ \ _/ ___\| |/ // __ \ / __ | | | | |/ \_/ __ \
  920. // | | | | \// __ \\ \___| <\ ___// /_/ | | | | | Y Y \ ___/
  921. // |____| |__| (____ /\___ >__|_ \\___ >____ | |____| |__|__|_| /\___ >
  922. // \/ \/ \/ \/ \/ \/ \/
  923. // ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.
  924. type ErrTrackedTimeNotExist struct {
  925. ID int64
  926. }
  927. // IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.
  928. func IsErrTrackedTimeNotExist(err error) bool {
  929. _, ok := err.(ErrTrackedTimeNotExist)
  930. return ok
  931. }
  932. func (err ErrTrackedTimeNotExist) Error() string {
  933. return fmt.Sprintf("tracked time does not exist [id: %d]", err.ID)
  934. }
  935. // .____ ___. .__
  936. // | | _____ \_ |__ ____ | |
  937. // | | \__ \ | __ \_/ __ \| |
  938. // | |___ / __ \| \_\ \ ___/| |__
  939. // |_______ (____ /___ /\___ >____/
  940. // \/ \/ \/ \/
  941. // ErrRepoLabelNotExist represents a "RepoLabelNotExist" kind of error.
  942. type ErrRepoLabelNotExist struct {
  943. LabelID int64
  944. RepoID int64
  945. }
  946. // IsErrRepoLabelNotExist checks if an error is a RepoErrLabelNotExist.
  947. func IsErrRepoLabelNotExist(err error) bool {
  948. _, ok := err.(ErrRepoLabelNotExist)
  949. return ok
  950. }
  951. func (err ErrRepoLabelNotExist) Error() string {
  952. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  953. }
  954. // ErrOrgLabelNotExist represents a "OrgLabelNotExist" kind of error.
  955. type ErrOrgLabelNotExist struct {
  956. LabelID int64
  957. OrgID int64
  958. }
  959. // IsErrOrgLabelNotExist checks if an error is a OrgErrLabelNotExist.
  960. func IsErrOrgLabelNotExist(err error) bool {
  961. _, ok := err.(ErrOrgLabelNotExist)
  962. return ok
  963. }
  964. func (err ErrOrgLabelNotExist) Error() string {
  965. return fmt.Sprintf("label does not exist [label_id: %d, org_id: %d]", err.LabelID, err.OrgID)
  966. }
  967. // ErrLabelNotExist represents a "LabelNotExist" kind of error.
  968. type ErrLabelNotExist struct {
  969. LabelID int64
  970. }
  971. // IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
  972. func IsErrLabelNotExist(err error) bool {
  973. _, ok := err.(ErrLabelNotExist)
  974. return ok
  975. }
  976. func (err ErrLabelNotExist) Error() string {
  977. return fmt.Sprintf("label does not exist [label_id: %d]", err.LabelID)
  978. }
  979. // __________ __ __
  980. // \______ \_______ ____ |__| ____ _____/ |_ ______
  981. // | ___/\_ __ \/ _ \ | |/ __ \_/ ___\ __\/ ___/
  982. // | | | | \( <_> ) | \ ___/\ \___| | \___ \
  983. // |____| |__| \____/\__| |\___ >\___ >__| /____ >
  984. // \______| \/ \/ \/
  985. // ErrProjectNotExist represents a "ProjectNotExist" kind of error.
  986. type ErrProjectNotExist struct {
  987. ID int64
  988. RepoID int64
  989. }
  990. // IsErrProjectNotExist checks if an error is a ErrProjectNotExist
  991. func IsErrProjectNotExist(err error) bool {
  992. _, ok := err.(ErrProjectNotExist)
  993. return ok
  994. }
  995. func (err ErrProjectNotExist) Error() string {
  996. return fmt.Sprintf("projects does not exist [id: %d]", err.ID)
  997. }
  998. // ErrProjectBoardNotExist represents a "ProjectBoardNotExist" kind of error.
  999. type ErrProjectBoardNotExist struct {
  1000. BoardID int64
  1001. }
  1002. // IsErrProjectBoardNotExist checks if an error is a ErrProjectBoardNotExist
  1003. func IsErrProjectBoardNotExist(err error) bool {
  1004. _, ok := err.(ErrProjectBoardNotExist)
  1005. return ok
  1006. }
  1007. func (err ErrProjectBoardNotExist) Error() string {
  1008. return fmt.Sprintf("project board does not exist [id: %d]", err.BoardID)
  1009. }
  1010. // _____ .__.__ __
  1011. // / \ |__| | ____ _______/ |_ ____ ____ ____
  1012. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  1013. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  1014. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  1015. // \/ \/ \/ \/ \/
  1016. // ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.
  1017. type ErrMilestoneNotExist struct {
  1018. ID int64
  1019. RepoID int64
  1020. Name string
  1021. }
  1022. // IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
  1023. func IsErrMilestoneNotExist(err error) bool {
  1024. _, ok := err.(ErrMilestoneNotExist)
  1025. return ok
  1026. }
  1027. func (err ErrMilestoneNotExist) Error() string {
  1028. if len(err.Name) > 0 {
  1029. return fmt.Sprintf("milestone does not exist [name: %s, repo_id: %d]", err.Name, err.RepoID)
  1030. }
  1031. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  1032. }
  1033. // ___________
  1034. // \__ ___/___ _____ _____
  1035. // | |_/ __ \\__ \ / \
  1036. // | |\ ___/ / __ \| Y Y \
  1037. // |____| \___ >____ /__|_| /
  1038. // \/ \/ \/
  1039. // ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
  1040. type ErrTeamAlreadyExist struct {
  1041. OrgID int64
  1042. Name string
  1043. }
  1044. // IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
  1045. func IsErrTeamAlreadyExist(err error) bool {
  1046. _, ok := err.(ErrTeamAlreadyExist)
  1047. return ok
  1048. }
  1049. func (err ErrTeamAlreadyExist) Error() string {
  1050. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  1051. }
  1052. // ErrTeamNotExist represents a "TeamNotExist" error
  1053. type ErrTeamNotExist struct {
  1054. OrgID int64
  1055. TeamID int64
  1056. Name string
  1057. }
  1058. // IsErrTeamNotExist checks if an error is a ErrTeamNotExist.
  1059. func IsErrTeamNotExist(err error) bool {
  1060. _, ok := err.(ErrTeamNotExist)
  1061. return ok
  1062. }
  1063. func (err ErrTeamNotExist) Error() string {
  1064. return fmt.Sprintf("team does not exist [org_id %d, team_id %d, name: %s]", err.OrgID, err.TeamID, err.Name)
  1065. }
  1066. // ____ ___ .__ .___
  1067. // | | \______ | | _________ __| _/
  1068. // | | /\____ \| | / _ \__ \ / __ |
  1069. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  1070. // |______/ | __/|____/\____(____ /\____ |
  1071. // |__| \/ \/
  1072. //
  1073. // ErrUploadNotExist represents a "UploadNotExist" kind of error.
  1074. type ErrUploadNotExist struct {
  1075. ID int64
  1076. UUID string
  1077. }
  1078. // IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
  1079. func IsErrUploadNotExist(err error) bool {
  1080. _, ok := err.(ErrUploadNotExist)
  1081. return ok
  1082. }
  1083. func (err ErrUploadNotExist) Error() string {
  1084. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1085. }
  1086. // .___ ________ .___ .__
  1087. // | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
  1088. // | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
  1089. // | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
  1090. // |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
  1091. // \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
  1092. // ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
  1093. type ErrDependencyExists struct {
  1094. IssueID int64
  1095. DependencyID int64
  1096. }
  1097. // IsErrDependencyExists checks if an error is a ErrDependencyExists.
  1098. func IsErrDependencyExists(err error) bool {
  1099. _, ok := err.(ErrDependencyExists)
  1100. return ok
  1101. }
  1102. func (err ErrDependencyExists) Error() string {
  1103. return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1104. }
  1105. // ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
  1106. type ErrDependencyNotExists struct {
  1107. IssueID int64
  1108. DependencyID int64
  1109. }
  1110. // IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
  1111. func IsErrDependencyNotExists(err error) bool {
  1112. _, ok := err.(ErrDependencyNotExists)
  1113. return ok
  1114. }
  1115. func (err ErrDependencyNotExists) Error() string {
  1116. return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1117. }
  1118. // ErrCircularDependency represents a "DependencyCircular" kind of error.
  1119. type ErrCircularDependency struct {
  1120. IssueID int64
  1121. DependencyID int64
  1122. }
  1123. // IsErrCircularDependency checks if an error is a ErrCircularDependency.
  1124. func IsErrCircularDependency(err error) bool {
  1125. _, ok := err.(ErrCircularDependency)
  1126. return ok
  1127. }
  1128. func (err ErrCircularDependency) Error() string {
  1129. return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1130. }
  1131. // ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
  1132. type ErrDependenciesLeft struct {
  1133. IssueID int64
  1134. }
  1135. // IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
  1136. func IsErrDependenciesLeft(err error) bool {
  1137. _, ok := err.(ErrDependenciesLeft)
  1138. return ok
  1139. }
  1140. func (err ErrDependenciesLeft) Error() string {
  1141. return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
  1142. }
  1143. // ErrUnknownDependencyType represents an error where an unknown dependency type was passed
  1144. type ErrUnknownDependencyType struct {
  1145. Type DependencyType
  1146. }
  1147. // IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
  1148. func IsErrUnknownDependencyType(err error) bool {
  1149. _, ok := err.(ErrUnknownDependencyType)
  1150. return ok
  1151. }
  1152. func (err ErrUnknownDependencyType) Error() string {
  1153. return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
  1154. }
  1155. // __________ .__
  1156. // \______ \ _______ _|__| ______ _ __
  1157. // | _// __ \ \/ / |/ __ \ \/ \/ /
  1158. // | | \ ___/\ /| \ ___/\ /
  1159. // |____|_ /\___ >\_/ |__|\___ >\/\_/
  1160. // \/ \/ \/
  1161. // ErrReviewNotExist represents a "ReviewNotExist" kind of error.
  1162. type ErrReviewNotExist struct {
  1163. ID int64
  1164. }
  1165. // IsErrReviewNotExist checks if an error is a ErrReviewNotExist.
  1166. func IsErrReviewNotExist(err error) bool {
  1167. _, ok := err.(ErrReviewNotExist)
  1168. return ok
  1169. }
  1170. func (err ErrReviewNotExist) Error() string {
  1171. return fmt.Sprintf("review does not exist [id: %d]", err.ID)
  1172. }
  1173. // ErrNotValidReviewRequest an not allowed review request modify
  1174. type ErrNotValidReviewRequest struct {
  1175. Reason string
  1176. UserID int64
  1177. RepoID int64
  1178. }
  1179. // IsErrNotValidReviewRequest checks if an error is a ErrNotValidReviewRequest.
  1180. func IsErrNotValidReviewRequest(err error) bool {
  1181. _, ok := err.(ErrNotValidReviewRequest)
  1182. return ok
  1183. }
  1184. func (err ErrNotValidReviewRequest) Error() string {
  1185. return fmt.Sprintf("%s [user_id: %d, repo_id: %d]",
  1186. err.Reason,
  1187. err.UserID,
  1188. err.RepoID)
  1189. }