error.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. import (
  6. "fmt"
  7. )
  8. type ErrNameReserved struct {
  9. Name string
  10. }
  11. func IsErrNameReserved(err error) bool {
  12. _, ok := err.(ErrNameReserved)
  13. return ok
  14. }
  15. func (err ErrNameReserved) Error() string {
  16. return fmt.Sprintf("name is reserved [name: %s]", err.Name)
  17. }
  18. type ErrNamePatternNotAllowed struct {
  19. Pattern string
  20. }
  21. func IsErrNamePatternNotAllowed(err error) bool {
  22. _, ok := err.(ErrNamePatternNotAllowed)
  23. return ok
  24. }
  25. func (err ErrNamePatternNotAllowed) Error() string {
  26. return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
  27. }
  28. // ____ ___
  29. // | | \______ ___________
  30. // | | / ___// __ \_ __ \
  31. // | | /\___ \\ ___/| | \/
  32. // |______//____ >\___ >__|
  33. // \/ \/
  34. type ErrUserAlreadyExist struct {
  35. Name string
  36. }
  37. func IsErrUserAlreadyExist(err error) bool {
  38. _, ok := err.(ErrUserAlreadyExist)
  39. return ok
  40. }
  41. func (err ErrUserAlreadyExist) Error() string {
  42. return fmt.Sprintf("user already exists [name: %s]", err.Name)
  43. }
  44. type ErrUserNotExist struct {
  45. UID int64
  46. Name string
  47. }
  48. func IsErrUserNotExist(err error) bool {
  49. _, ok := err.(ErrUserNotExist)
  50. return ok
  51. }
  52. func (err ErrUserNotExist) Error() string {
  53. return fmt.Sprintf("user does not exist [uid: %d, name: %s]", err.UID, err.Name)
  54. }
  55. type ErrEmailAlreadyUsed struct {
  56. Email string
  57. }
  58. func IsErrEmailAlreadyUsed(err error) bool {
  59. _, ok := err.(ErrEmailAlreadyUsed)
  60. return ok
  61. }
  62. func (err ErrEmailAlreadyUsed) Error() string {
  63. return fmt.Sprintf("e-mail has been used [email: %s]", err.Email)
  64. }
  65. type ErrUserOwnRepos struct {
  66. UID int64
  67. }
  68. func IsErrUserOwnRepos(err error) bool {
  69. _, ok := err.(ErrUserOwnRepos)
  70. return ok
  71. }
  72. func (err ErrUserOwnRepos) Error() string {
  73. return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
  74. }
  75. type ErrUserHasOrgs struct {
  76. UID int64
  77. }
  78. func IsErrUserHasOrgs(err error) bool {
  79. _, ok := err.(ErrUserHasOrgs)
  80. return ok
  81. }
  82. func (err ErrUserHasOrgs) Error() string {
  83. return fmt.Sprintf("user still has membership of organizations [uid: %d]", err.UID)
  84. }
  85. type ErrReachLimitOfRepo struct {
  86. Limit int
  87. }
  88. func IsErrReachLimitOfRepo(err error) bool {
  89. _, ok := err.(ErrReachLimitOfRepo)
  90. return ok
  91. }
  92. func (err ErrReachLimitOfRepo) Error() string {
  93. return fmt.Sprintf("user has reached maximum limit of repositories [limit: %d]", err.Limit)
  94. }
  95. // __ __.__ __ .__
  96. // / \ / \__| | _|__|
  97. // \ \/\/ / | |/ / |
  98. // \ /| | <| |
  99. // \__/\ / |__|__|_ \__|
  100. // \/ \/
  101. type ErrWikiAlreadyExist struct {
  102. Title string
  103. }
  104. func IsErrWikiAlreadyExist(err error) bool {
  105. _, ok := err.(ErrWikiAlreadyExist)
  106. return ok
  107. }
  108. func (err ErrWikiAlreadyExist) Error() string {
  109. return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
  110. }
  111. // __________ ___. .__ .__ ____ __.
  112. // \______ \__ _\_ |__ | | |__| ____ | |/ _|____ ___.__.
  113. // | ___/ | \ __ \| | | |/ ___\ | <_/ __ < | |
  114. // | | | | / \_\ \ |_| \ \___ | | \ ___/\___ |
  115. // |____| |____/|___ /____/__|\___ > |____|__ \___ > ____|
  116. // \/ \/ \/ \/\/
  117. type ErrKeyUnableVerify struct {
  118. Result string
  119. }
  120. func IsErrKeyUnableVerify(err error) bool {
  121. _, ok := err.(ErrKeyUnableVerify)
  122. return ok
  123. }
  124. func (err ErrKeyUnableVerify) Error() string {
  125. return fmt.Sprintf("Unable to verify key content [result: %s]", err.Result)
  126. }
  127. type ErrKeyNotExist struct {
  128. ID int64
  129. }
  130. func IsErrKeyNotExist(err error) bool {
  131. _, ok := err.(ErrKeyNotExist)
  132. return ok
  133. }
  134. func (err ErrKeyNotExist) Error() string {
  135. return fmt.Sprintf("public key does not exist [id: %d]", err.ID)
  136. }
  137. type ErrKeyAlreadyExist struct {
  138. OwnerID int64
  139. Content string
  140. }
  141. func IsErrKeyAlreadyExist(err error) bool {
  142. _, ok := err.(ErrKeyAlreadyExist)
  143. return ok
  144. }
  145. func (err ErrKeyAlreadyExist) Error() string {
  146. return fmt.Sprintf("public key already exists [owner_id: %d, content: %s]", err.OwnerID, err.Content)
  147. }
  148. type ErrKeyNameAlreadyUsed struct {
  149. OwnerID int64
  150. Name string
  151. }
  152. func IsErrKeyNameAlreadyUsed(err error) bool {
  153. _, ok := err.(ErrKeyNameAlreadyUsed)
  154. return ok
  155. }
  156. func (err ErrKeyNameAlreadyUsed) Error() string {
  157. return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
  158. }
  159. type ErrKeyAccessDenied struct {
  160. UserID int64
  161. KeyID int64
  162. Note string
  163. }
  164. func IsErrKeyAccessDenied(err error) bool {
  165. _, ok := err.(ErrKeyAccessDenied)
  166. return ok
  167. }
  168. func (err ErrKeyAccessDenied) Error() string {
  169. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d, note: %s]",
  170. err.UserID, err.KeyID, err.Note)
  171. }
  172. type ErrDeployKeyNotExist struct {
  173. ID int64
  174. KeyID int64
  175. RepoID int64
  176. }
  177. func IsErrDeployKeyNotExist(err error) bool {
  178. _, ok := err.(ErrDeployKeyNotExist)
  179. return ok
  180. }
  181. func (err ErrDeployKeyNotExist) Error() string {
  182. return fmt.Sprintf("Deploy key does not exist [id: %d, key_id: %d, repo_id: %d]", err.ID, err.KeyID, err.RepoID)
  183. }
  184. type ErrDeployKeyAlreadyExist struct {
  185. KeyID int64
  186. RepoID int64
  187. }
  188. func IsErrDeployKeyAlreadyExist(err error) bool {
  189. _, ok := err.(ErrDeployKeyAlreadyExist)
  190. return ok
  191. }
  192. func (err ErrDeployKeyAlreadyExist) Error() string {
  193. return fmt.Sprintf("public key already exists [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
  194. }
  195. type ErrDeployKeyNameAlreadyUsed struct {
  196. RepoID int64
  197. Name string
  198. }
  199. func IsErrDeployKeyNameAlreadyUsed(err error) bool {
  200. _, ok := err.(ErrDeployKeyNameAlreadyUsed)
  201. return ok
  202. }
  203. func (err ErrDeployKeyNameAlreadyUsed) Error() string {
  204. return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
  205. }
  206. // _____ ___________ __
  207. // / _ \ ____ ____ ____ ______ _____\__ ___/___ | | __ ____ ____
  208. // / /_\ \_/ ___\/ ___\/ __ \ / ___// ___/ | | / _ \| |/ // __ \ / \
  209. // / | \ \__\ \__\ ___/ \___ \ \___ \ | |( <_> ) <\ ___/| | \
  210. // \____|__ /\___ >___ >___ >____ >____ > |____| \____/|__|_ \\___ >___| /
  211. // \/ \/ \/ \/ \/ \/ \/ \/ \/
  212. type ErrAccessTokenNotExist struct {
  213. SHA string
  214. }
  215. func IsErrAccessTokenNotExist(err error) bool {
  216. _, ok := err.(ErrAccessTokenNotExist)
  217. return ok
  218. }
  219. func (err ErrAccessTokenNotExist) Error() string {
  220. return fmt.Sprintf("access token does not exist [sha: %s]", err.SHA)
  221. }
  222. type ErrAccessTokenEmpty struct {
  223. }
  224. func IsErrAccessTokenEmpty(err error) bool {
  225. _, ok := err.(ErrAccessTokenEmpty)
  226. return ok
  227. }
  228. func (err ErrAccessTokenEmpty) Error() string {
  229. return fmt.Sprintf("access token is empty")
  230. }
  231. // ________ .__ __ .__
  232. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  233. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  234. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  235. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  236. // \/ /_____/ \/ \/ \/ \/ \/
  237. type ErrLastOrgOwner struct {
  238. UID int64
  239. }
  240. func IsErrLastOrgOwner(err error) bool {
  241. _, ok := err.(ErrLastOrgOwner)
  242. return ok
  243. }
  244. func (err ErrLastOrgOwner) Error() string {
  245. return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
  246. }
  247. // __________ .__ __
  248. // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
  249. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
  250. // | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
  251. // |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
  252. // \/ \/|__| \/ \/
  253. type ErrRepoNotExist struct {
  254. ID int64
  255. UID int64
  256. Name string
  257. }
  258. func IsErrRepoNotExist(err error) bool {
  259. _, ok := err.(ErrRepoNotExist)
  260. return ok
  261. }
  262. func (err ErrRepoNotExist) Error() string {
  263. return fmt.Sprintf("repository does not exist [id: %d, uid: %d, name: %s]", err.ID, err.UID, err.Name)
  264. }
  265. type ErrRepoAlreadyExist struct {
  266. Uname string
  267. Name string
  268. }
  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. type ErrInvalidCloneAddr struct {
  277. IsURLError bool
  278. IsInvalidPath bool
  279. IsPermissionDenied bool
  280. }
  281. func IsErrInvalidCloneAddr(err error) bool {
  282. _, ok := err.(ErrInvalidCloneAddr)
  283. return ok
  284. }
  285. func (err ErrInvalidCloneAddr) Error() string {
  286. return fmt.Sprintf("invalid clone address [is_url_error: %v, is_invalid_path: %v, is_permission_denied: %v]",
  287. err.IsURLError, err.IsInvalidPath, err.IsPermissionDenied)
  288. }
  289. type ErrUpdateTaskNotExist struct {
  290. UUID string
  291. }
  292. func IsErrUpdateTaskNotExist(err error) bool {
  293. _, ok := err.(ErrUpdateTaskNotExist)
  294. return ok
  295. }
  296. func (err ErrUpdateTaskNotExist) Error() string {
  297. return fmt.Sprintf("update task does not exist [uuid: %s]", err.UUID)
  298. }
  299. type ErrReleaseAlreadyExist struct {
  300. TagName string
  301. }
  302. func IsErrReleaseAlreadyExist(err error) bool {
  303. _, ok := err.(ErrReleaseAlreadyExist)
  304. return ok
  305. }
  306. func (err ErrReleaseAlreadyExist) Error() string {
  307. return fmt.Sprintf("release tag already exist [tag_name: %s]", err.TagName)
  308. }
  309. type ErrReleaseNotExist struct {
  310. ID int64
  311. TagName string
  312. }
  313. func IsErrReleaseNotExist(err error) bool {
  314. _, ok := err.(ErrReleaseNotExist)
  315. return ok
  316. }
  317. func (err ErrReleaseNotExist) Error() string {
  318. return fmt.Sprintf("release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
  319. }
  320. type ErrInvalidTagName struct {
  321. TagName string
  322. }
  323. func IsErrInvalidTagName(err error) bool {
  324. _, ok := err.(ErrInvalidTagName)
  325. return ok
  326. }
  327. func (err ErrInvalidTagName) Error() string {
  328. return fmt.Sprintf("release tag name is not valid [tag_name: %s]", err.TagName)
  329. }
  330. type ErrRepoFileAlreadyExist struct {
  331. FileName string
  332. }
  333. func IsErrRepoFileAlreadyExist(err error) bool {
  334. _, ok := err.(ErrRepoFileAlreadyExist)
  335. return ok
  336. }
  337. func (err ErrRepoFileAlreadyExist) Error() string {
  338. return fmt.Sprintf("repository file already exists [file_name: %s]", err.FileName)
  339. }
  340. // __________ .__
  341. // \______ \____________ ____ ____ | |__
  342. // | | _/\_ __ \__ \ / \_/ ___\| | \
  343. // | | \ | | \// __ \| | \ \___| Y \
  344. // |______ / |__| (____ /___| /\___ >___| /
  345. // \/ \/ \/ \/ \/
  346. type ErrBranchNotExist struct {
  347. Name string
  348. }
  349. func IsErrBranchNotExist(err error) bool {
  350. _, ok := err.(ErrBranchNotExist)
  351. return ok
  352. }
  353. func (err ErrBranchNotExist) Error() string {
  354. return fmt.Sprintf("branch does not exist [name: %s]", err.Name)
  355. }
  356. // __ __ ___. .__ __
  357. // / \ / \ ____\_ |__ | |__ ____ ____ | | __
  358. // \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /
  359. // \ /\ ___/| \_\ \ Y ( <_> | <_> ) <
  360. // \__/\ / \___ >___ /___| /\____/ \____/|__|_ \
  361. // \/ \/ \/ \/ \/
  362. type ErrWebhookNotExist struct {
  363. ID int64
  364. }
  365. func IsErrWebhookNotExist(err error) bool {
  366. _, ok := err.(ErrWebhookNotExist)
  367. return ok
  368. }
  369. func (err ErrWebhookNotExist) Error() string {
  370. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  371. }
  372. // .___
  373. // | | ______ ________ __ ____
  374. // | |/ ___// ___/ | \_/ __ \
  375. // | |\___ \ \___ \| | /\ ___/
  376. // |___/____ >____ >____/ \___ >
  377. // \/ \/ \/
  378. type ErrIssueNotExist struct {
  379. ID int64
  380. RepoID int64
  381. Index int64
  382. }
  383. func IsErrIssueNotExist(err error) bool {
  384. _, ok := err.(ErrIssueNotExist)
  385. return ok
  386. }
  387. func (err ErrIssueNotExist) Error() string {
  388. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  389. }
  390. // __________ .__ .__ __________ __
  391. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  392. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  393. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  394. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  395. // \/ \/ |__| \/ \/
  396. type ErrPullRequestNotExist struct {
  397. ID int64
  398. IssueID int64
  399. HeadRepoID int64
  400. BaseRepoID int64
  401. HeadBarcnh string
  402. BaseBranch string
  403. }
  404. func IsErrPullRequestNotExist(err error) bool {
  405. _, ok := err.(ErrPullRequestNotExist)
  406. return ok
  407. }
  408. func (err ErrPullRequestNotExist) Error() string {
  409. 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]",
  410. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBarcnh, err.BaseBranch)
  411. }
  412. // _________ __
  413. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  414. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  415. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  416. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  417. // \/ \/ \/ \/ \/
  418. type ErrCommentNotExist struct {
  419. ID int64
  420. IssueID int64
  421. }
  422. func IsErrCommentNotExist(err error) bool {
  423. _, ok := err.(ErrCommentNotExist)
  424. return ok
  425. }
  426. func (err ErrCommentNotExist) Error() string {
  427. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  428. }
  429. // .____ ___. .__
  430. // | | _____ \_ |__ ____ | |
  431. // | | \__ \ | __ \_/ __ \| |
  432. // | |___ / __ \| \_\ \ ___/| |__
  433. // |_______ (____ /___ /\___ >____/
  434. // \/ \/ \/ \/
  435. type ErrLabelNotExist struct {
  436. LabelID int64
  437. RepoID int64
  438. }
  439. func IsErrLabelNotExist(err error) bool {
  440. _, ok := err.(ErrLabelNotExist)
  441. return ok
  442. }
  443. func (err ErrLabelNotExist) Error() string {
  444. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  445. }
  446. // _____ .__.__ __
  447. // / \ |__| | ____ _______/ |_ ____ ____ ____
  448. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  449. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  450. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  451. // \/ \/ \/ \/ \/
  452. type ErrMilestoneNotExist struct {
  453. ID int64
  454. RepoID int64
  455. }
  456. func IsErrMilestoneNotExist(err error) bool {
  457. _, ok := err.(ErrMilestoneNotExist)
  458. return ok
  459. }
  460. func (err ErrMilestoneNotExist) Error() string {
  461. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  462. }
  463. // _____ __ __ .__ __
  464. // / _ \_/ |__/ |______ ____ | |__ _____ ____ _____/ |_
  465. // / /_\ \ __\ __\__ \ _/ ___\| | \ / \_/ __ \ / \ __\
  466. // / | \ | | | / __ \\ \___| Y \ Y Y \ ___/| | \ |
  467. // \____|__ /__| |__| (____ /\___ >___| /__|_| /\___ >___| /__|
  468. // \/ \/ \/ \/ \/ \/ \/
  469. type ErrAttachmentNotExist struct {
  470. ID int64
  471. UUID string
  472. }
  473. func IsErrAttachmentNotExist(err error) bool {
  474. _, ok := err.(ErrAttachmentNotExist)
  475. return ok
  476. }
  477. func (err ErrAttachmentNotExist) Error() string {
  478. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  479. }
  480. // .____ .__ _________
  481. // | | ____ ____ |__| ____ / _____/ ____ __ _________ ____ ____
  482. // | | / _ \ / ___\| |/ \ \_____ \ / _ \| | \_ __ \_/ ___\/ __ \
  483. // | |__( <_> ) /_/ > | | \ / ( <_> ) | /| | \/\ \__\ ___/
  484. // |_______ \____/\___ /|__|___| / /_______ /\____/|____/ |__| \___ >___ >
  485. // \/ /_____/ \/ \/ \/ \/
  486. type ErrLoginSourceNotExist struct {
  487. ID int64
  488. }
  489. func IsErrLoginSourceNotExist(err error) bool {
  490. _, ok := err.(ErrLoginSourceNotExist)
  491. return ok
  492. }
  493. func (err ErrLoginSourceNotExist) Error() string {
  494. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  495. }
  496. type ErrLoginSourceAlreadyExist struct {
  497. Name string
  498. }
  499. func IsErrLoginSourceAlreadyExist(err error) bool {
  500. _, ok := err.(ErrLoginSourceAlreadyExist)
  501. return ok
  502. }
  503. func (err ErrLoginSourceAlreadyExist) Error() string {
  504. return fmt.Sprintf("login source already exists [name: %s]", err.Name)
  505. }
  506. type ErrLoginSourceInUse struct {
  507. ID int64
  508. }
  509. func IsErrLoginSourceInUse(err error) bool {
  510. _, ok := err.(ErrLoginSourceInUse)
  511. return ok
  512. }
  513. func (err ErrLoginSourceInUse) Error() string {
  514. return fmt.Sprintf("login source is still used by some users [id: %d]", err.ID)
  515. }
  516. // ___________
  517. // \__ ___/___ _____ _____
  518. // | |_/ __ \\__ \ / \
  519. // | |\ ___/ / __ \| Y Y \
  520. // |____| \___ >____ /__|_| /
  521. // \/ \/ \/
  522. type ErrTeamAlreadyExist struct {
  523. OrgID int64
  524. Name string
  525. }
  526. func IsErrTeamAlreadyExist(err error) bool {
  527. _, ok := err.(ErrTeamAlreadyExist)
  528. return ok
  529. }
  530. func (err ErrTeamAlreadyExist) Error() string {
  531. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  532. }
  533. // ____ ___ .__ .___
  534. // | | \______ | | _________ __| _/
  535. // | | /\____ \| | / _ \__ \ / __ |
  536. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  537. // |______/ | __/|____/\____(____ /\____ |
  538. // |__| \/ \/
  539. //
  540. type ErrUploadNotExist struct {
  541. ID int64
  542. UUID string
  543. }
  544. func IsErrUploadNotExist(err error) bool {
  545. _, ok := err.(ErrAttachmentNotExist)
  546. return ok
  547. }
  548. func (err ErrUploadNotExist) Error() string {
  549. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  550. }