選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

error.go 35KB

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