Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

error.go 35KB

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