Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  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/modules/git"
  9. )
  10. // ErrNotExist represents a non-exist error.
  11. type ErrNotExist struct {
  12. ID int64
  13. }
  14. // IsErrNotExist checks if an error is an ErrNotExist
  15. func IsErrNotExist(err error) bool {
  16. _, ok := err.(ErrNotExist)
  17. return ok
  18. }
  19. func (err ErrNotExist) Error() string {
  20. return fmt.Sprintf("record does not exist [id: %d]", err.ID)
  21. }
  22. // ErrNameReserved represents a "reserved name" error.
  23. type ErrNameReserved struct {
  24. Name string
  25. }
  26. // IsErrNameReserved checks if an error is a ErrNameReserved.
  27. func IsErrNameReserved(err error) bool {
  28. _, ok := err.(ErrNameReserved)
  29. return ok
  30. }
  31. func (err ErrNameReserved) Error() string {
  32. return fmt.Sprintf("name is reserved [name: %s]", err.Name)
  33. }
  34. // ErrNamePatternNotAllowed represents a "pattern not allowed" error.
  35. type ErrNamePatternNotAllowed struct {
  36. Pattern string
  37. }
  38. // IsErrNamePatternNotAllowed checks if an error is an ErrNamePatternNotAllowed.
  39. func IsErrNamePatternNotAllowed(err error) bool {
  40. _, ok := err.(ErrNamePatternNotAllowed)
  41. return ok
  42. }
  43. func (err ErrNamePatternNotAllowed) Error() string {
  44. return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
  45. }
  46. // ErrNameCharsNotAllowed represents a "character not allowed in name" error.
  47. type ErrNameCharsNotAllowed struct {
  48. Name string
  49. }
  50. // IsErrNameCharsNotAllowed checks if an error is an ErrNameCharsNotAllowed.
  51. func IsErrNameCharsNotAllowed(err error) bool {
  52. _, ok := err.(ErrNameCharsNotAllowed)
  53. return ok
  54. }
  55. func (err ErrNameCharsNotAllowed) Error() string {
  56. return fmt.Sprintf("User name is invalid [%s]: must be valid alpha or numeric or dash(-_) or dot characters", err.Name)
  57. }
  58. // ErrSSHDisabled represents an "SSH disabled" error.
  59. type ErrSSHDisabled struct {
  60. }
  61. // IsErrSSHDisabled checks if an error is a ErrSSHDisabled.
  62. func IsErrSSHDisabled(err error) bool {
  63. _, ok := err.(ErrSSHDisabled)
  64. return ok
  65. }
  66. func (err ErrSSHDisabled) Error() string {
  67. return "SSH is disabled"
  68. }
  69. // ErrCancelled represents an error due to context cancellation
  70. type ErrCancelled struct {
  71. Message string
  72. }
  73. // IsErrCancelled checks if an error is a ErrCancelled.
  74. func IsErrCancelled(err error) bool {
  75. _, ok := err.(ErrCancelled)
  76. return ok
  77. }
  78. func (err ErrCancelled) Error() string {
  79. return "Cancelled: " + err.Message
  80. }
  81. // ErrCancelledf returns an ErrCancelled for the provided format and args
  82. func ErrCancelledf(format string, args ...interface{}) error {
  83. return ErrCancelled{
  84. fmt.Sprintf(format, args...),
  85. }
  86. }
  87. // ____ ___
  88. // | | \______ ___________
  89. // | | / ___// __ \_ __ \
  90. // | | /\___ \\ ___/| | \/
  91. // |______//____ >\___ >__|
  92. // \/ \/
  93. // ErrUserAlreadyExist represents a "user already exists" error.
  94. type ErrUserAlreadyExist struct {
  95. Name string
  96. }
  97. // IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.
  98. func IsErrUserAlreadyExist(err error) bool {
  99. _, ok := err.(ErrUserAlreadyExist)
  100. return ok
  101. }
  102. func (err ErrUserAlreadyExist) Error() string {
  103. return fmt.Sprintf("user already exists [name: %s]", err.Name)
  104. }
  105. // ErrUserNotExist represents a "UserNotExist" kind of error.
  106. type ErrUserNotExist struct {
  107. UID int64
  108. Name string
  109. KeyID int64
  110. }
  111. // IsErrUserNotExist checks if an error is a ErrUserNotExist.
  112. func IsErrUserNotExist(err error) bool {
  113. _, ok := err.(ErrUserNotExist)
  114. return ok
  115. }
  116. func (err ErrUserNotExist) Error() string {
  117. return fmt.Sprintf("user does not exist [uid: %d, name: %s, keyid: %d]", err.UID, err.Name, err.KeyID)
  118. }
  119. // ErrUserRedirectNotExist represents a "UserRedirectNotExist" kind of error.
  120. type ErrUserRedirectNotExist struct {
  121. Name string
  122. }
  123. // IsErrUserRedirectNotExist check if an error is an ErrUserRedirectNotExist.
  124. func IsErrUserRedirectNotExist(err error) bool {
  125. _, ok := err.(ErrUserRedirectNotExist)
  126. return ok
  127. }
  128. func (err ErrUserRedirectNotExist) Error() string {
  129. return fmt.Sprintf("user redirect does not exist [name: %s]", err.Name)
  130. }
  131. // ErrUserProhibitLogin represents a "ErrUserProhibitLogin" kind of error.
  132. type ErrUserProhibitLogin struct {
  133. UID int64
  134. Name string
  135. }
  136. // IsErrUserProhibitLogin checks if an error is a ErrUserProhibitLogin
  137. func IsErrUserProhibitLogin(err error) bool {
  138. _, ok := err.(ErrUserProhibitLogin)
  139. return ok
  140. }
  141. func (err ErrUserProhibitLogin) Error() string {
  142. return fmt.Sprintf("user is not allowed login [uid: %d, name: %s]", err.UID, err.Name)
  143. }
  144. // ErrUserInactive represents a "ErrUserInactive" kind of error.
  145. type ErrUserInactive struct {
  146. UID int64
  147. Name string
  148. }
  149. // IsErrUserInactive checks if an error is a ErrUserInactive
  150. func IsErrUserInactive(err error) bool {
  151. _, ok := err.(ErrUserInactive)
  152. return ok
  153. }
  154. func (err ErrUserInactive) Error() string {
  155. return fmt.Sprintf("user is inactive [uid: %d, name: %s]", err.UID, err.Name)
  156. }
  157. // ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.
  158. type ErrEmailAlreadyUsed struct {
  159. Email string
  160. }
  161. // IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
  162. func IsErrEmailAlreadyUsed(err error) bool {
  163. _, ok := err.(ErrEmailAlreadyUsed)
  164. return ok
  165. }
  166. func (err ErrEmailAlreadyUsed) Error() string {
  167. return fmt.Sprintf("e-mail already in use [email: %s]", err.Email)
  168. }
  169. // ErrEmailInvalid represents an error where the email address does not comply with RFC 5322
  170. type ErrEmailInvalid struct {
  171. Email string
  172. }
  173. // IsErrEmailInvalid checks if an error is an ErrEmailInvalid
  174. func IsErrEmailInvalid(err error) bool {
  175. _, ok := err.(ErrEmailInvalid)
  176. return ok
  177. }
  178. func (err ErrEmailInvalid) Error() string {
  179. return fmt.Sprintf("e-mail invalid [email: %s]", err.Email)
  180. }
  181. // ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.
  182. type ErrOpenIDAlreadyUsed struct {
  183. OpenID string
  184. }
  185. // IsErrOpenIDAlreadyUsed checks if an error is a ErrOpenIDAlreadyUsed.
  186. func IsErrOpenIDAlreadyUsed(err error) bool {
  187. _, ok := err.(ErrOpenIDAlreadyUsed)
  188. return ok
  189. }
  190. func (err ErrOpenIDAlreadyUsed) Error() string {
  191. return fmt.Sprintf("OpenID already in use [oid: %s]", err.OpenID)
  192. }
  193. // ErrUserOwnRepos represents a "UserOwnRepos" kind of error.
  194. type ErrUserOwnRepos struct {
  195. UID int64
  196. }
  197. // IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.
  198. func IsErrUserOwnRepos(err error) bool {
  199. _, ok := err.(ErrUserOwnRepos)
  200. return ok
  201. }
  202. func (err ErrUserOwnRepos) Error() string {
  203. return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
  204. }
  205. // ErrUserHasOrgs represents a "UserHasOrgs" kind of error.
  206. type ErrUserHasOrgs struct {
  207. UID int64
  208. }
  209. // IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.
  210. func IsErrUserHasOrgs(err error) bool {
  211. _, ok := err.(ErrUserHasOrgs)
  212. return ok
  213. }
  214. func (err ErrUserHasOrgs) Error() string {
  215. return fmt.Sprintf("user still has membership of organizations [uid: %d]", err.UID)
  216. }
  217. // ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.
  218. type ErrUserNotAllowedCreateOrg struct {
  219. }
  220. // IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.
  221. func IsErrUserNotAllowedCreateOrg(err error) bool {
  222. _, ok := err.(ErrUserNotAllowedCreateOrg)
  223. return ok
  224. }
  225. func (err ErrUserNotAllowedCreateOrg) Error() string {
  226. return "user is not allowed to create organizations"
  227. }
  228. // ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.
  229. type ErrReachLimitOfRepo struct {
  230. Limit int
  231. }
  232. // IsErrReachLimitOfRepo checks if an error is a ErrReachLimitOfRepo.
  233. func IsErrReachLimitOfRepo(err error) bool {
  234. _, ok := err.(ErrReachLimitOfRepo)
  235. return ok
  236. }
  237. func (err ErrReachLimitOfRepo) Error() string {
  238. return fmt.Sprintf("user has reached maximum limit of repositories [limit: %d]", err.Limit)
  239. }
  240. // __ __.__ __ .__
  241. // / \ / \__| | _|__|
  242. // \ \/\/ / | |/ / |
  243. // \ /| | <| |
  244. // \__/\ / |__|__|_ \__|
  245. // \/ \/
  246. // ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.
  247. type ErrWikiAlreadyExist struct {
  248. Title string
  249. }
  250. // IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
  251. func IsErrWikiAlreadyExist(err error) bool {
  252. _, ok := err.(ErrWikiAlreadyExist)
  253. return ok
  254. }
  255. func (err ErrWikiAlreadyExist) Error() string {
  256. return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
  257. }
  258. // ErrWikiReservedName represents a reserved name error.
  259. type ErrWikiReservedName struct {
  260. Title string
  261. }
  262. // IsErrWikiReservedName checks if an error is an ErrWikiReservedName.
  263. func IsErrWikiReservedName(err error) bool {
  264. _, ok := err.(ErrWikiReservedName)
  265. return ok
  266. }
  267. func (err ErrWikiReservedName) Error() string {
  268. return fmt.Sprintf("wiki title is reserved: %s", err.Title)
  269. }
  270. // ErrWikiInvalidFileName represents an invalid wiki file name.
  271. type ErrWikiInvalidFileName struct {
  272. FileName string
  273. }
  274. // IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.
  275. func IsErrWikiInvalidFileName(err error) bool {
  276. _, ok := err.(ErrWikiInvalidFileName)
  277. return ok
  278. }
  279. func (err ErrWikiInvalidFileName) Error() string {
  280. return fmt.Sprintf("Invalid wiki filename: %s", err.FileName)
  281. }
  282. // __________ ___. .__ .__ ____ __.
  283. // \______ \__ _\_ |__ | | |__| ____ | |/ _|____ ___.__.
  284. // | ___/ | \ __ \| | | |/ ___\ | <_/ __ < | |
  285. // | | | | / \_\ \ |_| \ \___ | | \ ___/\___ |
  286. // |____| |____/|___ /____/__|\___ > |____|__ \___ > ____|
  287. // \/ \/ \/ \/\/
  288. // ErrKeyUnableVerify represents a "KeyUnableVerify" kind of error.
  289. type ErrKeyUnableVerify struct {
  290. Result string
  291. }
  292. // IsErrKeyUnableVerify checks if an error is a ErrKeyUnableVerify.
  293. func IsErrKeyUnableVerify(err error) bool {
  294. _, ok := err.(ErrKeyUnableVerify)
  295. return ok
  296. }
  297. func (err ErrKeyUnableVerify) Error() string {
  298. return fmt.Sprintf("Unable to verify key content [result: %s]", err.Result)
  299. }
  300. // ErrKeyNotExist represents a "KeyNotExist" kind of error.
  301. type ErrKeyNotExist struct {
  302. ID int64
  303. }
  304. // IsErrKeyNotExist checks if an error is a ErrKeyNotExist.
  305. func IsErrKeyNotExist(err error) bool {
  306. _, ok := err.(ErrKeyNotExist)
  307. return ok
  308. }
  309. func (err ErrKeyNotExist) Error() string {
  310. return fmt.Sprintf("public key does not exist [id: %d]", err.ID)
  311. }
  312. // ErrKeyAlreadyExist represents a "KeyAlreadyExist" kind of error.
  313. type ErrKeyAlreadyExist struct {
  314. OwnerID int64
  315. Fingerprint string
  316. Content string
  317. }
  318. // IsErrKeyAlreadyExist checks if an error is a ErrKeyAlreadyExist.
  319. func IsErrKeyAlreadyExist(err error) bool {
  320. _, ok := err.(ErrKeyAlreadyExist)
  321. return ok
  322. }
  323. func (err ErrKeyAlreadyExist) Error() string {
  324. return fmt.Sprintf("public key already exists [owner_id: %d, finger_print: %s, content: %s]",
  325. err.OwnerID, err.Fingerprint, err.Content)
  326. }
  327. // ErrKeyNameAlreadyUsed represents a "KeyNameAlreadyUsed" kind of error.
  328. type ErrKeyNameAlreadyUsed struct {
  329. OwnerID int64
  330. Name string
  331. }
  332. // IsErrKeyNameAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
  333. func IsErrKeyNameAlreadyUsed(err error) bool {
  334. _, ok := err.(ErrKeyNameAlreadyUsed)
  335. return ok
  336. }
  337. func (err ErrKeyNameAlreadyUsed) Error() string {
  338. return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
  339. }
  340. // ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
  341. type ErrGPGNoEmailFound struct {
  342. FailedEmails []string
  343. }
  344. // IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.
  345. func IsErrGPGNoEmailFound(err error) bool {
  346. _, ok := err.(ErrGPGNoEmailFound)
  347. return ok
  348. }
  349. func (err ErrGPGNoEmailFound) Error() string {
  350. return fmt.Sprintf("none of the emails attached to the GPG key could be found: %v", err.FailedEmails)
  351. }
  352. // ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.
  353. type ErrGPGKeyParsing struct {
  354. ParseError error
  355. }
  356. // IsErrGPGKeyParsing checks if an error is a ErrGPGKeyParsing.
  357. func IsErrGPGKeyParsing(err error) bool {
  358. _, ok := err.(ErrGPGKeyParsing)
  359. return ok
  360. }
  361. func (err ErrGPGKeyParsing) Error() string {
  362. return fmt.Sprintf("failed to parse gpg key %s", err.ParseError.Error())
  363. }
  364. // ErrGPGKeyNotExist represents a "GPGKeyNotExist" kind of error.
  365. type ErrGPGKeyNotExist struct {
  366. ID int64
  367. }
  368. // IsErrGPGKeyNotExist checks if an error is a ErrGPGKeyNotExist.
  369. func IsErrGPGKeyNotExist(err error) bool {
  370. _, ok := err.(ErrGPGKeyNotExist)
  371. return ok
  372. }
  373. func (err ErrGPGKeyNotExist) Error() string {
  374. return fmt.Sprintf("public gpg key does not exist [id: %d]", err.ID)
  375. }
  376. // ErrGPGKeyImportNotExist represents a "GPGKeyImportNotExist" kind of error.
  377. type ErrGPGKeyImportNotExist struct {
  378. ID string
  379. }
  380. // IsErrGPGKeyImportNotExist checks if an error is a ErrGPGKeyImportNotExist.
  381. func IsErrGPGKeyImportNotExist(err error) bool {
  382. _, ok := err.(ErrGPGKeyImportNotExist)
  383. return ok
  384. }
  385. func (err ErrGPGKeyImportNotExist) Error() string {
  386. return fmt.Sprintf("public gpg key import does not exist [id: %s]", err.ID)
  387. }
  388. // ErrGPGKeyIDAlreadyUsed represents a "GPGKeyIDAlreadyUsed" kind of error.
  389. type ErrGPGKeyIDAlreadyUsed struct {
  390. KeyID string
  391. }
  392. // IsErrGPGKeyIDAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.
  393. func IsErrGPGKeyIDAlreadyUsed(err error) bool {
  394. _, ok := err.(ErrGPGKeyIDAlreadyUsed)
  395. return ok
  396. }
  397. func (err ErrGPGKeyIDAlreadyUsed) Error() string {
  398. return fmt.Sprintf("public key already exists [key_id: %s]", err.KeyID)
  399. }
  400. // ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error.
  401. type ErrGPGKeyAccessDenied struct {
  402. UserID int64
  403. KeyID int64
  404. }
  405. // IsErrGPGKeyAccessDenied checks if an error is a ErrGPGKeyAccessDenied.
  406. func IsErrGPGKeyAccessDenied(err error) bool {
  407. _, ok := err.(ErrGPGKeyAccessDenied)
  408. return ok
  409. }
  410. // Error pretty-prints an error of type ErrGPGKeyAccessDenied.
  411. func (err ErrGPGKeyAccessDenied) Error() string {
  412. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d]",
  413. err.UserID, err.KeyID)
  414. }
  415. // ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error.
  416. type ErrKeyAccessDenied struct {
  417. UserID int64
  418. KeyID int64
  419. Note string
  420. }
  421. // IsErrKeyAccessDenied checks if an error is a ErrKeyAccessDenied.
  422. func IsErrKeyAccessDenied(err error) bool {
  423. _, ok := err.(ErrKeyAccessDenied)
  424. return ok
  425. }
  426. func (err ErrKeyAccessDenied) Error() string {
  427. return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d, note: %s]",
  428. err.UserID, err.KeyID, err.Note)
  429. }
  430. // ErrDeployKeyNotExist represents a "DeployKeyNotExist" kind of error.
  431. type ErrDeployKeyNotExist struct {
  432. ID int64
  433. KeyID int64
  434. RepoID int64
  435. }
  436. // IsErrDeployKeyNotExist checks if an error is a ErrDeployKeyNotExist.
  437. func IsErrDeployKeyNotExist(err error) bool {
  438. _, ok := err.(ErrDeployKeyNotExist)
  439. return ok
  440. }
  441. func (err ErrDeployKeyNotExist) Error() string {
  442. return fmt.Sprintf("Deploy key does not exist [id: %d, key_id: %d, repo_id: %d]", err.ID, err.KeyID, err.RepoID)
  443. }
  444. // ErrDeployKeyAlreadyExist represents a "DeployKeyAlreadyExist" kind of error.
  445. type ErrDeployKeyAlreadyExist struct {
  446. KeyID int64
  447. RepoID int64
  448. }
  449. // IsErrDeployKeyAlreadyExist checks if an error is a ErrDeployKeyAlreadyExist.
  450. func IsErrDeployKeyAlreadyExist(err error) bool {
  451. _, ok := err.(ErrDeployKeyAlreadyExist)
  452. return ok
  453. }
  454. func (err ErrDeployKeyAlreadyExist) Error() string {
  455. return fmt.Sprintf("public key already exists [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
  456. }
  457. // ErrDeployKeyNameAlreadyUsed represents a "DeployKeyNameAlreadyUsed" kind of error.
  458. type ErrDeployKeyNameAlreadyUsed struct {
  459. RepoID int64
  460. Name string
  461. }
  462. // IsErrDeployKeyNameAlreadyUsed checks if an error is a ErrDeployKeyNameAlreadyUsed.
  463. func IsErrDeployKeyNameAlreadyUsed(err error) bool {
  464. _, ok := err.(ErrDeployKeyNameAlreadyUsed)
  465. return ok
  466. }
  467. func (err ErrDeployKeyNameAlreadyUsed) Error() string {
  468. return fmt.Sprintf("public key with name already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
  469. }
  470. // _____ ___________ __
  471. // / _ \ ____ ____ ____ ______ _____\__ ___/___ | | __ ____ ____
  472. // / /_\ \_/ ___\/ ___\/ __ \ / ___// ___/ | | / _ \| |/ // __ \ / \
  473. // / | \ \__\ \__\ ___/ \___ \ \___ \ | |( <_> ) <\ ___/| | \
  474. // \____|__ /\___ >___ >___ >____ >____ > |____| \____/|__|_ \\___ >___| /
  475. // \/ \/ \/ \/ \/ \/ \/ \/ \/
  476. // ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.
  477. type ErrAccessTokenNotExist struct {
  478. Token string
  479. }
  480. // IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.
  481. func IsErrAccessTokenNotExist(err error) bool {
  482. _, ok := err.(ErrAccessTokenNotExist)
  483. return ok
  484. }
  485. func (err ErrAccessTokenNotExist) Error() string {
  486. return fmt.Sprintf("access token does not exist [sha: %s]", err.Token)
  487. }
  488. // ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.
  489. type ErrAccessTokenEmpty struct {
  490. }
  491. // IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.
  492. func IsErrAccessTokenEmpty(err error) bool {
  493. _, ok := err.(ErrAccessTokenEmpty)
  494. return ok
  495. }
  496. func (err ErrAccessTokenEmpty) Error() string {
  497. return "access token is empty"
  498. }
  499. // ________ .__ __ .__
  500. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  501. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  502. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  503. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  504. // \/ /_____/ \/ \/ \/ \/ \/
  505. // ErrOrgNotExist represents a "OrgNotExist" kind of error.
  506. type ErrOrgNotExist struct {
  507. ID int64
  508. Name string
  509. }
  510. // IsErrOrgNotExist checks if an error is a ErrOrgNotExist.
  511. func IsErrOrgNotExist(err error) bool {
  512. _, ok := err.(ErrOrgNotExist)
  513. return ok
  514. }
  515. func (err ErrOrgNotExist) Error() string {
  516. return fmt.Sprintf("org does not exist [id: %d, name: %s]", err.ID, err.Name)
  517. }
  518. // ErrLastOrgOwner represents a "LastOrgOwner" kind of error.
  519. type ErrLastOrgOwner struct {
  520. UID int64
  521. }
  522. // IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.
  523. func IsErrLastOrgOwner(err error) bool {
  524. _, ok := err.(ErrLastOrgOwner)
  525. return ok
  526. }
  527. func (err ErrLastOrgOwner) Error() string {
  528. return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
  529. }
  530. //.____ ____________________
  531. //| | \_ _____/ _____/
  532. //| | | __) \_____ \
  533. //| |___| \ / \
  534. //|_______ \___ / /_______ /
  535. // \/ \/ \/
  536. // ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
  537. type ErrLFSLockNotExist struct {
  538. ID int64
  539. RepoID int64
  540. Path string
  541. }
  542. // IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.
  543. func IsErrLFSLockNotExist(err error) bool {
  544. _, ok := err.(ErrLFSLockNotExist)
  545. return ok
  546. }
  547. func (err ErrLFSLockNotExist) Error() string {
  548. return fmt.Sprintf("lfs lock does not exist [id: %d, rid: %d, path: %s]", err.ID, err.RepoID, err.Path)
  549. }
  550. // ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.
  551. type ErrLFSUnauthorizedAction struct {
  552. RepoID int64
  553. UserName string
  554. Mode AccessMode
  555. }
  556. // IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.
  557. func IsErrLFSUnauthorizedAction(err error) bool {
  558. _, ok := err.(ErrLFSUnauthorizedAction)
  559. return ok
  560. }
  561. func (err ErrLFSUnauthorizedAction) Error() string {
  562. if err.Mode == AccessModeWrite {
  563. return fmt.Sprintf("User %s doesn't have write access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  564. }
  565. return fmt.Sprintf("User %s doesn't have read access for lfs lock [rid: %d]", err.UserName, err.RepoID)
  566. }
  567. // ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
  568. type ErrLFSLockAlreadyExist struct {
  569. RepoID int64
  570. Path string
  571. }
  572. // IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.
  573. func IsErrLFSLockAlreadyExist(err error) bool {
  574. _, ok := err.(ErrLFSLockAlreadyExist)
  575. return ok
  576. }
  577. func (err ErrLFSLockAlreadyExist) Error() string {
  578. return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
  579. }
  580. // ErrLFSFileLocked represents a "LFSFileLocked" kind of error.
  581. type ErrLFSFileLocked struct {
  582. RepoID int64
  583. Path string
  584. UserName string
  585. }
  586. // IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.
  587. func IsErrLFSFileLocked(err error) bool {
  588. _, ok := err.(ErrLFSFileLocked)
  589. return ok
  590. }
  591. func (err ErrLFSFileLocked) Error() string {
  592. return fmt.Sprintf("File is lfs locked [repo: %d, locked by: %s, path: %s]", err.RepoID, err.UserName, err.Path)
  593. }
  594. // __________ .__ __
  595. // \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
  596. // | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
  597. // | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
  598. // |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
  599. // \/ \/|__| \/ \/
  600. // ErrRepoNotExist represents a "RepoNotExist" kind of error.
  601. type ErrRepoNotExist struct {
  602. ID int64
  603. UID int64
  604. OwnerName string
  605. Name string
  606. }
  607. // IsErrRepoNotExist checks if an error is a ErrRepoNotExist.
  608. func IsErrRepoNotExist(err error) bool {
  609. _, ok := err.(ErrRepoNotExist)
  610. return ok
  611. }
  612. func (err ErrRepoNotExist) Error() string {
  613. return fmt.Sprintf("repository does not exist [id: %d, uid: %d, owner_name: %s, name: %s]",
  614. err.ID, err.UID, err.OwnerName, err.Name)
  615. }
  616. // ErrRepoAlreadyExist represents a "RepoAlreadyExist" kind of error.
  617. type ErrRepoAlreadyExist struct {
  618. Uname string
  619. Name string
  620. }
  621. // IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.
  622. func IsErrRepoAlreadyExist(err error) bool {
  623. _, ok := err.(ErrRepoAlreadyExist)
  624. return ok
  625. }
  626. func (err ErrRepoAlreadyExist) Error() string {
  627. return fmt.Sprintf("repository already exists [uname: %s, name: %s]", err.Uname, err.Name)
  628. }
  629. // ErrRepoFilesAlreadyExist represents a "RepoFilesAlreadyExist" kind of error.
  630. type ErrRepoFilesAlreadyExist struct {
  631. Uname string
  632. Name string
  633. }
  634. // IsErrRepoFilesAlreadyExist checks if an error is a ErrRepoAlreadyExist.
  635. func IsErrRepoFilesAlreadyExist(err error) bool {
  636. _, ok := err.(ErrRepoFilesAlreadyExist)
  637. return ok
  638. }
  639. func (err ErrRepoFilesAlreadyExist) Error() string {
  640. return fmt.Sprintf("repository files already exist [uname: %s, name: %s]", err.Uname, err.Name)
  641. }
  642. // ErrForkAlreadyExist represents a "ForkAlreadyExist" kind of error.
  643. type ErrForkAlreadyExist struct {
  644. Uname string
  645. RepoName string
  646. ForkName string
  647. }
  648. // IsErrForkAlreadyExist checks if an error is an ErrForkAlreadyExist.
  649. func IsErrForkAlreadyExist(err error) bool {
  650. _, ok := err.(ErrForkAlreadyExist)
  651. return ok
  652. }
  653. func (err ErrForkAlreadyExist) Error() string {
  654. return fmt.Sprintf("repository is already forked by user [uname: %s, repo path: %s, fork path: %s]", err.Uname, err.RepoName, err.ForkName)
  655. }
  656. // ErrRepoRedirectNotExist represents a "RepoRedirectNotExist" kind of error.
  657. type ErrRepoRedirectNotExist struct {
  658. OwnerID int64
  659. RepoName string
  660. }
  661. // IsErrRepoRedirectNotExist check if an error is an ErrRepoRedirectNotExist.
  662. func IsErrRepoRedirectNotExist(err error) bool {
  663. _, ok := err.(ErrRepoRedirectNotExist)
  664. return ok
  665. }
  666. func (err ErrRepoRedirectNotExist) Error() string {
  667. return fmt.Sprintf("repository redirect does not exist [uid: %d, name: %s]", err.OwnerID, err.RepoName)
  668. }
  669. // ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.
  670. type ErrInvalidCloneAddr struct {
  671. IsURLError bool
  672. IsInvalidPath bool
  673. IsPermissionDenied bool
  674. }
  675. // IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
  676. func IsErrInvalidCloneAddr(err error) bool {
  677. _, ok := err.(ErrInvalidCloneAddr)
  678. return ok
  679. }
  680. func (err ErrInvalidCloneAddr) Error() string {
  681. return fmt.Sprintf("invalid clone address [is_url_error: %v, is_invalid_path: %v, is_permission_denied: %v]",
  682. err.IsURLError, err.IsInvalidPath, err.IsPermissionDenied)
  683. }
  684. // ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.
  685. type ErrUpdateTaskNotExist struct {
  686. UUID string
  687. }
  688. // IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.
  689. func IsErrUpdateTaskNotExist(err error) bool {
  690. _, ok := err.(ErrUpdateTaskNotExist)
  691. return ok
  692. }
  693. func (err ErrUpdateTaskNotExist) Error() string {
  694. return fmt.Sprintf("update task does not exist [uuid: %s]", err.UUID)
  695. }
  696. // ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.
  697. type ErrReleaseAlreadyExist struct {
  698. TagName string
  699. }
  700. // IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.
  701. func IsErrReleaseAlreadyExist(err error) bool {
  702. _, ok := err.(ErrReleaseAlreadyExist)
  703. return ok
  704. }
  705. func (err ErrReleaseAlreadyExist) Error() string {
  706. return fmt.Sprintf("release tag already exist [tag_name: %s]", err.TagName)
  707. }
  708. // ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.
  709. type ErrReleaseNotExist struct {
  710. ID int64
  711. TagName string
  712. }
  713. // IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.
  714. func IsErrReleaseNotExist(err error) bool {
  715. _, ok := err.(ErrReleaseNotExist)
  716. return ok
  717. }
  718. func (err ErrReleaseNotExist) Error() string {
  719. return fmt.Sprintf("release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
  720. }
  721. // ErrInvalidTagName represents a "InvalidTagName" kind of error.
  722. type ErrInvalidTagName struct {
  723. TagName string
  724. }
  725. // IsErrInvalidTagName checks if an error is a ErrInvalidTagName.
  726. func IsErrInvalidTagName(err error) bool {
  727. _, ok := err.(ErrInvalidTagName)
  728. return ok
  729. }
  730. func (err ErrInvalidTagName) Error() string {
  731. return fmt.Sprintf("release tag name is not valid [tag_name: %s]", err.TagName)
  732. }
  733. // ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.
  734. type ErrRepoFileAlreadyExists struct {
  735. Path string
  736. }
  737. // IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.
  738. func IsErrRepoFileAlreadyExists(err error) bool {
  739. _, ok := err.(ErrRepoFileAlreadyExists)
  740. return ok
  741. }
  742. func (err ErrRepoFileAlreadyExists) Error() string {
  743. return fmt.Sprintf("repository file already exists [path: %s]", err.Path)
  744. }
  745. // ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.
  746. type ErrRepoFileDoesNotExist struct {
  747. Path string
  748. Name string
  749. }
  750. // IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.
  751. func IsErrRepoFileDoesNotExist(err error) bool {
  752. _, ok := err.(ErrRepoFileDoesNotExist)
  753. return ok
  754. }
  755. func (err ErrRepoFileDoesNotExist) Error() string {
  756. return fmt.Sprintf("repository file does not exist [path: %s]", err.Path)
  757. }
  758. // ErrFilenameInvalid represents a "FilenameInvalid" kind of error.
  759. type ErrFilenameInvalid struct {
  760. Path string
  761. }
  762. // IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.
  763. func IsErrFilenameInvalid(err error) bool {
  764. _, ok := err.(ErrFilenameInvalid)
  765. return ok
  766. }
  767. func (err ErrFilenameInvalid) Error() string {
  768. return fmt.Sprintf("path contains a malformed path component [path: %s]", err.Path)
  769. }
  770. // ErrUserCannotCommit represents "UserCannotCommit" kind of error.
  771. type ErrUserCannotCommit struct {
  772. UserName string
  773. }
  774. // IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.
  775. func IsErrUserCannotCommit(err error) bool {
  776. _, ok := err.(ErrUserCannotCommit)
  777. return ok
  778. }
  779. func (err ErrUserCannotCommit) Error() string {
  780. return fmt.Sprintf("user cannot commit to repo [user: %s]", err.UserName)
  781. }
  782. // ErrFilePathInvalid represents a "FilePathInvalid" kind of error.
  783. type ErrFilePathInvalid struct {
  784. Message string
  785. Path string
  786. Name string
  787. Type git.EntryMode
  788. }
  789. // IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.
  790. func IsErrFilePathInvalid(err error) bool {
  791. _, ok := err.(ErrFilePathInvalid)
  792. return ok
  793. }
  794. func (err ErrFilePathInvalid) Error() string {
  795. if err.Message != "" {
  796. return err.Message
  797. }
  798. return fmt.Sprintf("path is invalid [path: %s]", err.Path)
  799. }
  800. // ErrFilePathProtected represents a "FilePathProtected" kind of error.
  801. type ErrFilePathProtected struct {
  802. Message string
  803. Path string
  804. }
  805. // IsErrFilePathProtected checks if an error is an ErrFilePathProtected.
  806. func IsErrFilePathProtected(err error) bool {
  807. _, ok := err.(ErrFilePathProtected)
  808. return ok
  809. }
  810. func (err ErrFilePathProtected) Error() string {
  811. if err.Message != "" {
  812. return err.Message
  813. }
  814. return fmt.Sprintf("path is protected and can not be changed [path: %s]", err.Path)
  815. }
  816. // ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo.
  817. type ErrUserDoesNotHaveAccessToRepo struct {
  818. UserID int64
  819. RepoName string
  820. }
  821. // IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExists.
  822. func IsErrUserDoesNotHaveAccessToRepo(err error) bool {
  823. _, ok := err.(ErrUserDoesNotHaveAccessToRepo)
  824. return ok
  825. }
  826. func (err ErrUserDoesNotHaveAccessToRepo) Error() string {
  827. return fmt.Sprintf("user doesn't have acces to repo [user_id: %d, repo_name: %s]", err.UserID, err.RepoName)
  828. }
  829. // ErrWontSign explains the first reason why a commit would not be signed
  830. // There may be other reasons - this is just the first reason found
  831. type ErrWontSign struct {
  832. Reason signingMode
  833. }
  834. func (e *ErrWontSign) Error() string {
  835. return fmt.Sprintf("wont sign: %s", e.Reason)
  836. }
  837. // IsErrWontSign checks if an error is a ErrWontSign
  838. func IsErrWontSign(err error) bool {
  839. _, ok := err.(*ErrWontSign)
  840. return ok
  841. }
  842. // ErrMigrationNotAllowed explains why a migration from an url is not allowed
  843. type ErrMigrationNotAllowed struct {
  844. Host string
  845. NotResolvedIP bool
  846. PrivateNet string
  847. }
  848. func (e *ErrMigrationNotAllowed) Error() string {
  849. if e.NotResolvedIP {
  850. return fmt.Sprintf("migrate from '%s' is not allowed: unknown hostname", e.Host)
  851. }
  852. if len(e.PrivateNet) != 0 {
  853. return fmt.Sprintf("migrate from '%s' is not allowed: the host resolve to a private ip address '%s'", e.Host, e.PrivateNet)
  854. }
  855. return fmt.Sprintf("migrate from '%s is not allowed'", e.Host)
  856. }
  857. // IsErrMigrationNotAllowed checks if an error is a ErrMigrationNotAllowed
  858. func IsErrMigrationNotAllowed(err error) bool {
  859. _, ok := err.(*ErrMigrationNotAllowed)
  860. return ok
  861. }
  862. // __________ .__
  863. // \______ \____________ ____ ____ | |__
  864. // | | _/\_ __ \__ \ / \_/ ___\| | \
  865. // | | \ | | \// __ \| | \ \___| Y \
  866. // |______ / |__| (____ /___| /\___ >___| /
  867. // \/ \/ \/ \/ \/
  868. // ErrBranchDoesNotExist represents an error that branch with such name does not exist.
  869. type ErrBranchDoesNotExist struct {
  870. BranchName string
  871. }
  872. // IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.
  873. func IsErrBranchDoesNotExist(err error) bool {
  874. _, ok := err.(ErrBranchDoesNotExist)
  875. return ok
  876. }
  877. func (err ErrBranchDoesNotExist) Error() string {
  878. return fmt.Sprintf("branch does not exist [name: %s]", err.BranchName)
  879. }
  880. // ErrBranchAlreadyExists represents an error that branch with such name already exists.
  881. type ErrBranchAlreadyExists struct {
  882. BranchName string
  883. }
  884. // IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
  885. func IsErrBranchAlreadyExists(err error) bool {
  886. _, ok := err.(ErrBranchAlreadyExists)
  887. return ok
  888. }
  889. func (err ErrBranchAlreadyExists) Error() string {
  890. return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
  891. }
  892. // ErrBranchNameConflict represents an error that branch name conflicts with other branch.
  893. type ErrBranchNameConflict struct {
  894. BranchName string
  895. }
  896. // IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
  897. func IsErrBranchNameConflict(err error) bool {
  898. _, ok := err.(ErrBranchNameConflict)
  899. return ok
  900. }
  901. func (err ErrBranchNameConflict) Error() string {
  902. return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
  903. }
  904. // ErrBranchesEqual represents an error that branch name conflicts with other branch.
  905. type ErrBranchesEqual struct {
  906. BaseBranchName string
  907. HeadBranchName string
  908. }
  909. // IsErrBranchesEqual checks if an error is an ErrBranchesEqual.
  910. func IsErrBranchesEqual(err error) bool {
  911. _, ok := err.(ErrBranchesEqual)
  912. return ok
  913. }
  914. func (err ErrBranchesEqual) Error() string {
  915. return fmt.Sprintf("branches are equal [head: %sm base: %s]", err.HeadBranchName, err.BaseBranchName)
  916. }
  917. // ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
  918. type ErrNotAllowedToMerge struct {
  919. Reason string
  920. }
  921. // IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
  922. func IsErrNotAllowedToMerge(err error) bool {
  923. _, ok := err.(ErrNotAllowedToMerge)
  924. return ok
  925. }
  926. func (err ErrNotAllowedToMerge) Error() string {
  927. return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
  928. }
  929. // ErrTagAlreadyExists represents an error that tag with such name already exists.
  930. type ErrTagAlreadyExists struct {
  931. TagName string
  932. }
  933. // IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.
  934. func IsErrTagAlreadyExists(err error) bool {
  935. _, ok := err.(ErrTagAlreadyExists)
  936. return ok
  937. }
  938. func (err ErrTagAlreadyExists) Error() string {
  939. return fmt.Sprintf("tag already exists [name: %s]", err.TagName)
  940. }
  941. // ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.
  942. type ErrSHADoesNotMatch struct {
  943. Path string
  944. GivenSHA string
  945. CurrentSHA string
  946. }
  947. // IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.
  948. func IsErrSHADoesNotMatch(err error) bool {
  949. _, ok := err.(ErrSHADoesNotMatch)
  950. return ok
  951. }
  952. func (err ErrSHADoesNotMatch) Error() string {
  953. return fmt.Sprintf("sha does not match [given: %s, expected: %s]", err.GivenSHA, err.CurrentSHA)
  954. }
  955. // ErrSHANotFound represents a "SHADoesNotMatch" kind of error.
  956. type ErrSHANotFound struct {
  957. SHA string
  958. }
  959. // IsErrSHANotFound checks if an error is a ErrSHANotFound.
  960. func IsErrSHANotFound(err error) bool {
  961. _, ok := err.(ErrSHANotFound)
  962. return ok
  963. }
  964. func (err ErrSHANotFound) Error() string {
  965. return fmt.Sprintf("sha not found [%s]", err.SHA)
  966. }
  967. // ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.
  968. type ErrCommitIDDoesNotMatch struct {
  969. GivenCommitID string
  970. CurrentCommitID string
  971. }
  972. // IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.
  973. func IsErrCommitIDDoesNotMatch(err error) bool {
  974. _, ok := err.(ErrCommitIDDoesNotMatch)
  975. return ok
  976. }
  977. func (err ErrCommitIDDoesNotMatch) Error() string {
  978. return fmt.Sprintf("file CommitID does not match [given: %s, expected: %s]", err.GivenCommitID, err.CurrentCommitID)
  979. }
  980. // ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.
  981. type ErrSHAOrCommitIDNotProvided struct{}
  982. // IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.
  983. func IsErrSHAOrCommitIDNotProvided(err error) bool {
  984. _, ok := err.(ErrSHAOrCommitIDNotProvided)
  985. return ok
  986. }
  987. func (err ErrSHAOrCommitIDNotProvided) Error() string {
  988. return "a SHA or commmit ID must be proved when updating a file"
  989. }
  990. // __ __ ___. .__ __
  991. // / \ / \ ____\_ |__ | |__ ____ ____ | | __
  992. // \ \/\/ // __ \| __ \| | \ / _ \ / _ \| |/ /
  993. // \ /\ ___/| \_\ \ Y ( <_> | <_> ) <
  994. // \__/\ / \___ >___ /___| /\____/ \____/|__|_ \
  995. // \/ \/ \/ \/ \/
  996. // ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
  997. type ErrWebhookNotExist struct {
  998. ID int64
  999. }
  1000. // IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
  1001. func IsErrWebhookNotExist(err error) bool {
  1002. _, ok := err.(ErrWebhookNotExist)
  1003. return ok
  1004. }
  1005. func (err ErrWebhookNotExist) Error() string {
  1006. return fmt.Sprintf("webhook does not exist [id: %d]", err.ID)
  1007. }
  1008. // .___
  1009. // | | ______ ________ __ ____
  1010. // | |/ ___// ___/ | \_/ __ \
  1011. // | |\___ \ \___ \| | /\ ___/
  1012. // |___/____ >____ >____/ \___ >
  1013. // \/ \/ \/
  1014. // ErrIssueNotExist represents a "IssueNotExist" kind of error.
  1015. type ErrIssueNotExist struct {
  1016. ID int64
  1017. RepoID int64
  1018. Index int64
  1019. }
  1020. // IsErrIssueNotExist checks if an error is a ErrIssueNotExist.
  1021. func IsErrIssueNotExist(err error) bool {
  1022. _, ok := err.(ErrIssueNotExist)
  1023. return ok
  1024. }
  1025. func (err ErrIssueNotExist) Error() string {
  1026. return fmt.Sprintf("issue does not exist [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  1027. }
  1028. // ErrIssueIsClosed represents a "IssueIsClosed" kind of error.
  1029. type ErrIssueIsClosed struct {
  1030. ID int64
  1031. RepoID int64
  1032. Index int64
  1033. }
  1034. // IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.
  1035. func IsErrIssueIsClosed(err error) bool {
  1036. _, ok := err.(ErrIssueIsClosed)
  1037. return ok
  1038. }
  1039. func (err ErrIssueIsClosed) Error() string {
  1040. return fmt.Sprintf("issue is closed [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index)
  1041. }
  1042. // ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.
  1043. type ErrIssueLabelTemplateLoad struct {
  1044. TemplateFile string
  1045. OriginalError error
  1046. }
  1047. // IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.
  1048. func IsErrIssueLabelTemplateLoad(err error) bool {
  1049. _, ok := err.(ErrIssueLabelTemplateLoad)
  1050. return ok
  1051. }
  1052. func (err ErrIssueLabelTemplateLoad) Error() string {
  1053. return fmt.Sprintf("Failed to load label template file '%s': %v", err.TemplateFile, err.OriginalError)
  1054. }
  1055. // ErrNewIssueInsert is used when the INSERT statement in newIssue fails
  1056. type ErrNewIssueInsert struct {
  1057. OriginalError error
  1058. }
  1059. // IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.
  1060. func IsErrNewIssueInsert(err error) bool {
  1061. _, ok := err.(ErrNewIssueInsert)
  1062. return ok
  1063. }
  1064. func (err ErrNewIssueInsert) Error() string {
  1065. return err.OriginalError.Error()
  1066. }
  1067. // ErrIssueWasClosed is used when close a closed issue
  1068. type ErrIssueWasClosed struct {
  1069. ID int64
  1070. Index int64
  1071. }
  1072. // IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.
  1073. func IsErrIssueWasClosed(err error) bool {
  1074. _, ok := err.(ErrIssueWasClosed)
  1075. return ok
  1076. }
  1077. func (err ErrIssueWasClosed) Error() string {
  1078. return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index)
  1079. }
  1080. // ErrPullWasClosed is used close a closed pull request
  1081. type ErrPullWasClosed struct {
  1082. ID int64
  1083. Index int64
  1084. }
  1085. // IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed.
  1086. func IsErrPullWasClosed(err error) bool {
  1087. _, ok := err.(ErrPullWasClosed)
  1088. return ok
  1089. }
  1090. func (err ErrPullWasClosed) Error() string {
  1091. return fmt.Sprintf("Pull request [%d] %d was already closed", err.ID, err.Index)
  1092. }
  1093. // ErrForbiddenIssueReaction is used when a forbidden reaction was try to created
  1094. type ErrForbiddenIssueReaction struct {
  1095. Reaction string
  1096. }
  1097. // IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.
  1098. func IsErrForbiddenIssueReaction(err error) bool {
  1099. _, ok := err.(ErrForbiddenIssueReaction)
  1100. return ok
  1101. }
  1102. func (err ErrForbiddenIssueReaction) Error() string {
  1103. return fmt.Sprintf("'%s' is not an allowed reaction", err.Reaction)
  1104. }
  1105. // ErrReactionAlreadyExist is used when a existing reaction was try to created
  1106. type ErrReactionAlreadyExist struct {
  1107. Reaction string
  1108. }
  1109. // IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist.
  1110. func IsErrReactionAlreadyExist(err error) bool {
  1111. _, ok := err.(ErrReactionAlreadyExist)
  1112. return ok
  1113. }
  1114. func (err ErrReactionAlreadyExist) Error() string {
  1115. return fmt.Sprintf("reaction '%s' already exists", err.Reaction)
  1116. }
  1117. // __________ .__ .__ __________ __
  1118. // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
  1119. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  1120. // | | | | / |_| |_| | \ ___< <_| | | /\ ___/ \___ \ | |
  1121. // |____| |____/|____/____/____|_ /\___ >__ |____/ \___ >____ > |__|
  1122. // \/ \/ |__| \/ \/
  1123. // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
  1124. type ErrPullRequestNotExist struct {
  1125. ID int64
  1126. IssueID int64
  1127. HeadRepoID int64
  1128. BaseRepoID int64
  1129. HeadBranch string
  1130. BaseBranch string
  1131. }
  1132. // IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.
  1133. func IsErrPullRequestNotExist(err error) bool {
  1134. _, ok := err.(ErrPullRequestNotExist)
  1135. return ok
  1136. }
  1137. func (err ErrPullRequestNotExist) Error() string {
  1138. 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]",
  1139. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1140. }
  1141. // ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error
  1142. type ErrPullRequestAlreadyExists struct {
  1143. ID int64
  1144. IssueID int64
  1145. HeadRepoID int64
  1146. BaseRepoID int64
  1147. HeadBranch string
  1148. BaseBranch string
  1149. }
  1150. // IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.
  1151. func IsErrPullRequestAlreadyExists(err error) bool {
  1152. _, ok := err.(ErrPullRequestAlreadyExists)
  1153. return ok
  1154. }
  1155. // Error does pretty-printing :D
  1156. func (err ErrPullRequestAlreadyExists) Error() string {
  1157. 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]",
  1158. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1159. }
  1160. // ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error
  1161. type ErrPullRequestHeadRepoMissing struct {
  1162. ID int64
  1163. HeadRepoID int64
  1164. }
  1165. // IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.
  1166. func IsErrErrPullRequestHeadRepoMissing(err error) bool {
  1167. _, ok := err.(ErrPullRequestHeadRepoMissing)
  1168. return ok
  1169. }
  1170. // Error does pretty-printing :D
  1171. func (err ErrPullRequestHeadRepoMissing) Error() string {
  1172. return fmt.Sprintf("pull request head repo missing [id: %d, head_repo_id: %d]",
  1173. err.ID, err.HeadRepoID)
  1174. }
  1175. // ErrInvalidMergeStyle represents an error if merging with disabled merge strategy
  1176. type ErrInvalidMergeStyle struct {
  1177. ID int64
  1178. Style MergeStyle
  1179. }
  1180. // IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.
  1181. func IsErrInvalidMergeStyle(err error) bool {
  1182. _, ok := err.(ErrInvalidMergeStyle)
  1183. return ok
  1184. }
  1185. func (err ErrInvalidMergeStyle) Error() string {
  1186. return fmt.Sprintf("merge strategy is not allowed or is invalid [repo_id: %d, strategy: %s]",
  1187. err.ID, err.Style)
  1188. }
  1189. // ErrMergeConflicts represents an error if merging fails with a conflict
  1190. type ErrMergeConflicts struct {
  1191. Style MergeStyle
  1192. StdOut string
  1193. StdErr string
  1194. Err error
  1195. }
  1196. // IsErrMergeConflicts checks if an error is a ErrMergeConflicts.
  1197. func IsErrMergeConflicts(err error) bool {
  1198. _, ok := err.(ErrMergeConflicts)
  1199. return ok
  1200. }
  1201. func (err ErrMergeConflicts) Error() string {
  1202. return fmt.Sprintf("Merge Conflict Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1203. }
  1204. // ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories
  1205. type ErrMergeUnrelatedHistories struct {
  1206. Style MergeStyle
  1207. StdOut string
  1208. StdErr string
  1209. Err error
  1210. }
  1211. // IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.
  1212. func IsErrMergeUnrelatedHistories(err error) bool {
  1213. _, ok := err.(ErrMergeUnrelatedHistories)
  1214. return ok
  1215. }
  1216. func (err ErrMergeUnrelatedHistories) Error() string {
  1217. return fmt.Sprintf("Merge UnrelatedHistories Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
  1218. }
  1219. // ErrRebaseConflicts represents an error if rebase fails with a conflict
  1220. type ErrRebaseConflicts struct {
  1221. Style MergeStyle
  1222. CommitSHA string
  1223. StdOut string
  1224. StdErr string
  1225. Err error
  1226. }
  1227. // IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.
  1228. func IsErrRebaseConflicts(err error) bool {
  1229. _, ok := err.(ErrRebaseConflicts)
  1230. return ok
  1231. }
  1232. func (err ErrRebaseConflicts) Error() string {
  1233. return fmt.Sprintf("Rebase Error: %v: Whilst Rebasing: %s\n%s\n%s", err.Err, err.CommitSHA, err.StdErr, err.StdOut)
  1234. }
  1235. // ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error
  1236. type ErrPullRequestHasMerged struct {
  1237. ID int64
  1238. IssueID int64
  1239. HeadRepoID int64
  1240. BaseRepoID int64
  1241. HeadBranch string
  1242. BaseBranch string
  1243. }
  1244. // IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.
  1245. func IsErrPullRequestHasMerged(err error) bool {
  1246. _, ok := err.(ErrPullRequestHasMerged)
  1247. return ok
  1248. }
  1249. // Error does pretty-printing :D
  1250. func (err ErrPullRequestHasMerged) Error() string {
  1251. 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]",
  1252. err.ID, err.IssueID, err.HeadRepoID, err.BaseRepoID, err.HeadBranch, err.BaseBranch)
  1253. }
  1254. // _________ __
  1255. // \_ ___ \ ____ _____ _____ ____ _____/ |_
  1256. // / \ \/ / _ \ / \ / \_/ __ \ / \ __\
  1257. // \ \___( <_> ) Y Y \ Y Y \ ___/| | \ |
  1258. // \______ /\____/|__|_| /__|_| /\___ >___| /__|
  1259. // \/ \/ \/ \/ \/
  1260. // ErrCommentNotExist represents a "CommentNotExist" kind of error.
  1261. type ErrCommentNotExist struct {
  1262. ID int64
  1263. IssueID int64
  1264. }
  1265. // IsErrCommentNotExist checks if an error is a ErrCommentNotExist.
  1266. func IsErrCommentNotExist(err error) bool {
  1267. _, ok := err.(ErrCommentNotExist)
  1268. return ok
  1269. }
  1270. func (err ErrCommentNotExist) Error() string {
  1271. return fmt.Sprintf("comment does not exist [id: %d, issue_id: %d]", err.ID, err.IssueID)
  1272. }
  1273. // _________ __ __ .__
  1274. // / _____// |_ ____ ________ _ _______ _/ |_ ____ | |__
  1275. // \_____ \\ __\/ _ \\____ \ \/ \/ /\__ \\ __\/ ___\| | \
  1276. // / \| | ( <_> ) |_> > / / __ \| | \ \___| Y \
  1277. // /_______ /|__| \____/| __/ \/\_/ (____ /__| \___ >___| /
  1278. // \/ |__| \/ \/ \/
  1279. // ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.
  1280. type ErrStopwatchNotExist struct {
  1281. ID int64
  1282. }
  1283. // IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.
  1284. func IsErrStopwatchNotExist(err error) bool {
  1285. _, ok := err.(ErrStopwatchNotExist)
  1286. return ok
  1287. }
  1288. func (err ErrStopwatchNotExist) Error() string {
  1289. return fmt.Sprintf("stopwatch does not exist [id: %d]", err.ID)
  1290. }
  1291. // ___________ __ .______________.__
  1292. // \__ ___/___________ ____ | | __ ____ __| _/\__ ___/|__| _____ ____
  1293. // | | \_ __ \__ \ _/ ___\| |/ // __ \ / __ | | | | |/ \_/ __ \
  1294. // | | | | \// __ \\ \___| <\ ___// /_/ | | | | | Y Y \ ___/
  1295. // |____| |__| (____ /\___ >__|_ \\___ >____ | |____| |__|__|_| /\___ >
  1296. // \/ \/ \/ \/ \/ \/ \/
  1297. // ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.
  1298. type ErrTrackedTimeNotExist struct {
  1299. ID int64
  1300. }
  1301. // IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.
  1302. func IsErrTrackedTimeNotExist(err error) bool {
  1303. _, ok := err.(ErrTrackedTimeNotExist)
  1304. return ok
  1305. }
  1306. func (err ErrTrackedTimeNotExist) Error() string {
  1307. return fmt.Sprintf("tracked time does not exist [id: %d]", err.ID)
  1308. }
  1309. // .____ ___. .__
  1310. // | | _____ \_ |__ ____ | |
  1311. // | | \__ \ | __ \_/ __ \| |
  1312. // | |___ / __ \| \_\ \ ___/| |__
  1313. // |_______ (____ /___ /\___ >____/
  1314. // \/ \/ \/ \/
  1315. // ErrRepoLabelNotExist represents a "RepoLabelNotExist" kind of error.
  1316. type ErrRepoLabelNotExist struct {
  1317. LabelID int64
  1318. RepoID int64
  1319. }
  1320. // IsErrRepoLabelNotExist checks if an error is a RepoErrLabelNotExist.
  1321. func IsErrRepoLabelNotExist(err error) bool {
  1322. _, ok := err.(ErrRepoLabelNotExist)
  1323. return ok
  1324. }
  1325. func (err ErrRepoLabelNotExist) Error() string {
  1326. return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
  1327. }
  1328. // ErrOrgLabelNotExist represents a "OrgLabelNotExist" kind of error.
  1329. type ErrOrgLabelNotExist struct {
  1330. LabelID int64
  1331. OrgID int64
  1332. }
  1333. // IsErrOrgLabelNotExist checks if an error is a OrgErrLabelNotExist.
  1334. func IsErrOrgLabelNotExist(err error) bool {
  1335. _, ok := err.(ErrOrgLabelNotExist)
  1336. return ok
  1337. }
  1338. func (err ErrOrgLabelNotExist) Error() string {
  1339. return fmt.Sprintf("label does not exist [label_id: %d, org_id: %d]", err.LabelID, err.OrgID)
  1340. }
  1341. // ErrLabelNotExist represents a "LabelNotExist" kind of error.
  1342. type ErrLabelNotExist struct {
  1343. LabelID int64
  1344. }
  1345. // IsErrLabelNotExist checks if an error is a ErrLabelNotExist.
  1346. func IsErrLabelNotExist(err error) bool {
  1347. _, ok := err.(ErrLabelNotExist)
  1348. return ok
  1349. }
  1350. func (err ErrLabelNotExist) Error() string {
  1351. return fmt.Sprintf("label does not exist [label_id: %d]", err.LabelID)
  1352. }
  1353. // __________ __ __
  1354. // \______ \_______ ____ |__| ____ _____/ |_ ______
  1355. // | ___/\_ __ \/ _ \ | |/ __ \_/ ___\ __\/ ___/
  1356. // | | | | \( <_> ) | \ ___/\ \___| | \___ \
  1357. // |____| |__| \____/\__| |\___ >\___ >__| /____ >
  1358. // \______| \/ \/ \/
  1359. // ErrProjectNotExist represents a "ProjectNotExist" kind of error.
  1360. type ErrProjectNotExist struct {
  1361. ID int64
  1362. RepoID int64
  1363. }
  1364. // IsErrProjectNotExist checks if an error is a ErrProjectNotExist
  1365. func IsErrProjectNotExist(err error) bool {
  1366. _, ok := err.(ErrProjectNotExist)
  1367. return ok
  1368. }
  1369. func (err ErrProjectNotExist) Error() string {
  1370. return fmt.Sprintf("projects does not exist [id: %d]", err.ID)
  1371. }
  1372. // ErrProjectBoardNotExist represents a "ProjectBoardNotExist" kind of error.
  1373. type ErrProjectBoardNotExist struct {
  1374. BoardID int64
  1375. }
  1376. // IsErrProjectBoardNotExist checks if an error is a ErrProjectBoardNotExist
  1377. func IsErrProjectBoardNotExist(err error) bool {
  1378. _, ok := err.(ErrProjectBoardNotExist)
  1379. return ok
  1380. }
  1381. func (err ErrProjectBoardNotExist) Error() string {
  1382. return fmt.Sprintf("project board does not exist [id: %d]", err.BoardID)
  1383. }
  1384. // _____ .__.__ __
  1385. // / \ |__| | ____ _______/ |_ ____ ____ ____
  1386. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  1387. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  1388. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  1389. // \/ \/ \/ \/ \/
  1390. // ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.
  1391. type ErrMilestoneNotExist struct {
  1392. ID int64
  1393. RepoID int64
  1394. Name string
  1395. }
  1396. // IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.
  1397. func IsErrMilestoneNotExist(err error) bool {
  1398. _, ok := err.(ErrMilestoneNotExist)
  1399. return ok
  1400. }
  1401. func (err ErrMilestoneNotExist) Error() string {
  1402. if len(err.Name) > 0 {
  1403. return fmt.Sprintf("milestone does not exist [name: %s, repo_id: %d]", err.Name, err.RepoID)
  1404. }
  1405. return fmt.Sprintf("milestone does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
  1406. }
  1407. // _____ __ __ .__ __
  1408. // / _ \_/ |__/ |______ ____ | |__ _____ ____ _____/ |_
  1409. // / /_\ \ __\ __\__ \ _/ ___\| | \ / \_/ __ \ / \ __\
  1410. // / | \ | | | / __ \\ \___| Y \ Y Y \ ___/| | \ |
  1411. // \____|__ /__| |__| (____ /\___ >___| /__|_| /\___ >___| /__|
  1412. // \/ \/ \/ \/ \/ \/ \/
  1413. // ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.
  1414. type ErrAttachmentNotExist struct {
  1415. ID int64
  1416. UUID string
  1417. }
  1418. // IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.
  1419. func IsErrAttachmentNotExist(err error) bool {
  1420. _, ok := err.(ErrAttachmentNotExist)
  1421. return ok
  1422. }
  1423. func (err ErrAttachmentNotExist) Error() string {
  1424. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1425. }
  1426. // .____ .__ _________
  1427. // | | ____ ____ |__| ____ / _____/ ____ __ _________ ____ ____
  1428. // | | / _ \ / ___\| |/ \ \_____ \ / _ \| | \_ __ \_/ ___\/ __ \
  1429. // | |__( <_> ) /_/ > | | \ / ( <_> ) | /| | \/\ \__\ ___/
  1430. // |_______ \____/\___ /|__|___| / /_______ /\____/|____/ |__| \___ >___ >
  1431. // \/ /_____/ \/ \/ \/ \/
  1432. // ErrLoginSourceNotExist represents a "LoginSourceNotExist" kind of error.
  1433. type ErrLoginSourceNotExist struct {
  1434. ID int64
  1435. }
  1436. // IsErrLoginSourceNotExist checks if an error is a ErrLoginSourceNotExist.
  1437. func IsErrLoginSourceNotExist(err error) bool {
  1438. _, ok := err.(ErrLoginSourceNotExist)
  1439. return ok
  1440. }
  1441. func (err ErrLoginSourceNotExist) Error() string {
  1442. return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
  1443. }
  1444. // ErrLoginSourceAlreadyExist represents a "LoginSourceAlreadyExist" kind of error.
  1445. type ErrLoginSourceAlreadyExist struct {
  1446. Name string
  1447. }
  1448. // IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.
  1449. func IsErrLoginSourceAlreadyExist(err error) bool {
  1450. _, ok := err.(ErrLoginSourceAlreadyExist)
  1451. return ok
  1452. }
  1453. func (err ErrLoginSourceAlreadyExist) Error() string {
  1454. return fmt.Sprintf("login source already exists [name: %s]", err.Name)
  1455. }
  1456. // ErrLoginSourceInUse represents a "LoginSourceInUse" kind of error.
  1457. type ErrLoginSourceInUse struct {
  1458. ID int64
  1459. }
  1460. // IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.
  1461. func IsErrLoginSourceInUse(err error) bool {
  1462. _, ok := err.(ErrLoginSourceInUse)
  1463. return ok
  1464. }
  1465. func (err ErrLoginSourceInUse) Error() string {
  1466. return fmt.Sprintf("login source is still used by some users [id: %d]", err.ID)
  1467. }
  1468. // ___________
  1469. // \__ ___/___ _____ _____
  1470. // | |_/ __ \\__ \ / \
  1471. // | |\ ___/ / __ \| Y Y \
  1472. // |____| \___ >____ /__|_| /
  1473. // \/ \/ \/
  1474. // ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
  1475. type ErrTeamAlreadyExist struct {
  1476. OrgID int64
  1477. Name string
  1478. }
  1479. // IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
  1480. func IsErrTeamAlreadyExist(err error) bool {
  1481. _, ok := err.(ErrTeamAlreadyExist)
  1482. return ok
  1483. }
  1484. func (err ErrTeamAlreadyExist) Error() string {
  1485. return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name)
  1486. }
  1487. // ErrTeamNotExist represents a "TeamNotExist" error
  1488. type ErrTeamNotExist struct {
  1489. OrgID int64
  1490. TeamID int64
  1491. Name string
  1492. }
  1493. // IsErrTeamNotExist checks if an error is a ErrTeamNotExist.
  1494. func IsErrTeamNotExist(err error) bool {
  1495. _, ok := err.(ErrTeamNotExist)
  1496. return ok
  1497. }
  1498. func (err ErrTeamNotExist) Error() string {
  1499. return fmt.Sprintf("team does not exist [org_id %d, team_id %d, name: %s]", err.OrgID, err.TeamID, err.Name)
  1500. }
  1501. //
  1502. // Two-factor authentication
  1503. //
  1504. // ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication.
  1505. type ErrTwoFactorNotEnrolled struct {
  1506. UID int64
  1507. }
  1508. // IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled.
  1509. func IsErrTwoFactorNotEnrolled(err error) bool {
  1510. _, ok := err.(ErrTwoFactorNotEnrolled)
  1511. return ok
  1512. }
  1513. func (err ErrTwoFactorNotEnrolled) Error() string {
  1514. return fmt.Sprintf("user not enrolled in 2FA [uid: %d]", err.UID)
  1515. }
  1516. // ____ ___ .__ .___
  1517. // | | \______ | | _________ __| _/
  1518. // | | /\____ \| | / _ \__ \ / __ |
  1519. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  1520. // |______/ | __/|____/\____(____ /\____ |
  1521. // |__| \/ \/
  1522. //
  1523. // ErrUploadNotExist represents a "UploadNotExist" kind of error.
  1524. type ErrUploadNotExist struct {
  1525. ID int64
  1526. UUID string
  1527. }
  1528. // IsErrUploadNotExist checks if an error is a ErrUploadNotExist.
  1529. func IsErrUploadNotExist(err error) bool {
  1530. _, ok := err.(ErrAttachmentNotExist)
  1531. return ok
  1532. }
  1533. func (err ErrUploadNotExist) Error() string {
  1534. return fmt.Sprintf("attachment does not exist [id: %d, uuid: %s]", err.ID, err.UUID)
  1535. }
  1536. // ___________ __ .__ .____ .__ ____ ___
  1537. // \_ _____/__ ____/ |_ ___________ ____ _____ | | | | ____ ____ |__| ____ | | \______ ___________
  1538. // | __)_\ \/ /\ __\/ __ \_ __ \/ \\__ \ | | | | / _ \ / ___\| |/ \ | | / ___// __ \_ __ \
  1539. // | \> < | | \ ___/| | \/ | \/ __ \| |__ | |__( <_> ) /_/ > | | \ | | /\___ \\ ___/| | \/
  1540. // /_______ /__/\_ \ |__| \___ >__| |___| (____ /____/ |_______ \____/\___ /|__|___| / |______//____ >\___ >__|
  1541. // \/ \/ \/ \/ \/ \/ /_____/ \/ \/ \/
  1542. // ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
  1543. type ErrExternalLoginUserAlreadyExist struct {
  1544. ExternalID string
  1545. UserID int64
  1546. LoginSourceID int64
  1547. }
  1548. // IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.
  1549. func IsErrExternalLoginUserAlreadyExist(err error) bool {
  1550. _, ok := err.(ErrExternalLoginUserAlreadyExist)
  1551. return ok
  1552. }
  1553. func (err ErrExternalLoginUserAlreadyExist) Error() string {
  1554. return fmt.Sprintf("external login user already exists [externalID: %s, userID: %d, loginSourceID: %d]", err.ExternalID, err.UserID, err.LoginSourceID)
  1555. }
  1556. // ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
  1557. type ErrExternalLoginUserNotExist struct {
  1558. UserID int64
  1559. LoginSourceID int64
  1560. }
  1561. // IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.
  1562. func IsErrExternalLoginUserNotExist(err error) bool {
  1563. _, ok := err.(ErrExternalLoginUserNotExist)
  1564. return ok
  1565. }
  1566. func (err ErrExternalLoginUserNotExist) Error() string {
  1567. return fmt.Sprintf("external login user link does not exists [userID: %d, loginSourceID: %d]", err.UserID, err.LoginSourceID)
  1568. }
  1569. // ____ ________________________________ .__ __ __ .__
  1570. // | | \_____ \_ _____/\______ \ ____ ____ |__| _______/ |_____________ _/ |_|__| ____ ____
  1571. // | | // ____/| __) | _// __ \ / ___\| |/ ___/\ __\_ __ \__ \\ __\ |/ _ \ / \
  1572. // | | // \| \ | | \ ___// /_/ > |\___ \ | | | | \// __ \| | | ( <_> ) | \
  1573. // |______/ \_______ \___ / |____|_ /\___ >___ /|__/____ > |__| |__| (____ /__| |__|\____/|___| /
  1574. // \/ \/ \/ \/_____/ \/ \/ \/
  1575. // ErrU2FRegistrationNotExist represents a "ErrU2FRegistrationNotExist" kind of error.
  1576. type ErrU2FRegistrationNotExist struct {
  1577. ID int64
  1578. }
  1579. func (err ErrU2FRegistrationNotExist) Error() string {
  1580. return fmt.Sprintf("U2F registration does not exist [id: %d]", err.ID)
  1581. }
  1582. // IsErrU2FRegistrationNotExist checks if an error is a ErrU2FRegistrationNotExist.
  1583. func IsErrU2FRegistrationNotExist(err error) bool {
  1584. _, ok := err.(ErrU2FRegistrationNotExist)
  1585. return ok
  1586. }
  1587. // .___ ________ .___ .__
  1588. // | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
  1589. // | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
  1590. // | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
  1591. // |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
  1592. // \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
  1593. // ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
  1594. type ErrDependencyExists struct {
  1595. IssueID int64
  1596. DependencyID int64
  1597. }
  1598. // IsErrDependencyExists checks if an error is a ErrDependencyExists.
  1599. func IsErrDependencyExists(err error) bool {
  1600. _, ok := err.(ErrDependencyExists)
  1601. return ok
  1602. }
  1603. func (err ErrDependencyExists) Error() string {
  1604. return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1605. }
  1606. // ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
  1607. type ErrDependencyNotExists struct {
  1608. IssueID int64
  1609. DependencyID int64
  1610. }
  1611. // IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
  1612. func IsErrDependencyNotExists(err error) bool {
  1613. _, ok := err.(ErrDependencyNotExists)
  1614. return ok
  1615. }
  1616. func (err ErrDependencyNotExists) Error() string {
  1617. return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1618. }
  1619. // ErrCircularDependency represents a "DependencyCircular" kind of error.
  1620. type ErrCircularDependency struct {
  1621. IssueID int64
  1622. DependencyID int64
  1623. }
  1624. // IsErrCircularDependency checks if an error is a ErrCircularDependency.
  1625. func IsErrCircularDependency(err error) bool {
  1626. _, ok := err.(ErrCircularDependency)
  1627. return ok
  1628. }
  1629. func (err ErrCircularDependency) Error() string {
  1630. return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
  1631. }
  1632. // ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
  1633. type ErrDependenciesLeft struct {
  1634. IssueID int64
  1635. }
  1636. // IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
  1637. func IsErrDependenciesLeft(err error) bool {
  1638. _, ok := err.(ErrDependenciesLeft)
  1639. return ok
  1640. }
  1641. func (err ErrDependenciesLeft) Error() string {
  1642. return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
  1643. }
  1644. // ErrUnknownDependencyType represents an error where an unknown dependency type was passed
  1645. type ErrUnknownDependencyType struct {
  1646. Type DependencyType
  1647. }
  1648. // IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
  1649. func IsErrUnknownDependencyType(err error) bool {
  1650. _, ok := err.(ErrUnknownDependencyType)
  1651. return ok
  1652. }
  1653. func (err ErrUnknownDependencyType) Error() string {
  1654. return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
  1655. }
  1656. // __________ .__
  1657. // \______ \ _______ _|__| ______ _ __
  1658. // | _// __ \ \/ / |/ __ \ \/ \/ /
  1659. // | | \ ___/\ /| \ ___/\ /
  1660. // |____|_ /\___ >\_/ |__|\___ >\/\_/
  1661. // \/ \/ \/
  1662. // ErrReviewNotExist represents a "ReviewNotExist" kind of error.
  1663. type ErrReviewNotExist struct {
  1664. ID int64
  1665. }
  1666. // IsErrReviewNotExist checks if an error is a ErrReviewNotExist.
  1667. func IsErrReviewNotExist(err error) bool {
  1668. _, ok := err.(ErrReviewNotExist)
  1669. return ok
  1670. }
  1671. func (err ErrReviewNotExist) Error() string {
  1672. return fmt.Sprintf("review does not exist [id: %d]", err.ID)
  1673. }
  1674. // ErrNotValidReviewRequest an not allowed review request modify
  1675. type ErrNotValidReviewRequest struct {
  1676. Reason string
  1677. UserID int64
  1678. RepoID int64
  1679. }
  1680. // IsErrNotValidReviewRequest checks if an error is a ErrNotValidReviewRequest.
  1681. func IsErrNotValidReviewRequest(err error) bool {
  1682. _, ok := err.(ErrNotValidReviewRequest)
  1683. return ok
  1684. }
  1685. func (err ErrNotValidReviewRequest) Error() string {
  1686. return fmt.Sprintf("%s [user_id: %d, repo_id: %d]",
  1687. err.Reason,
  1688. err.UserID,
  1689. err.RepoID)
  1690. }
  1691. // ________ _____ __ .__
  1692. // \_____ \ / _ \ __ ___/ |_| |__
  1693. // / | \ / /_\ \| | \ __\ | \
  1694. // / | \/ | \ | /| | | Y \
  1695. // \_______ /\____|__ /____/ |__| |___| /
  1696. // \/ \/ \/
  1697. // ErrOAuthClientIDInvalid will be thrown if client id cannot be found
  1698. type ErrOAuthClientIDInvalid struct {
  1699. ClientID string
  1700. }
  1701. // IsErrOauthClientIDInvalid checks if an error is a ErrReviewNotExist.
  1702. func IsErrOauthClientIDInvalid(err error) bool {
  1703. _, ok := err.(ErrOAuthClientIDInvalid)
  1704. return ok
  1705. }
  1706. // Error returns the error message
  1707. func (err ErrOAuthClientIDInvalid) Error() string {
  1708. return fmt.Sprintf("Client ID invalid [Client ID: %s]", err.ClientID)
  1709. }
  1710. // ErrOAuthApplicationNotFound will be thrown if id cannot be found
  1711. type ErrOAuthApplicationNotFound struct {
  1712. ID int64
  1713. }
  1714. // IsErrOAuthApplicationNotFound checks if an error is a ErrReviewNotExist.
  1715. func IsErrOAuthApplicationNotFound(err error) bool {
  1716. _, ok := err.(ErrOAuthApplicationNotFound)
  1717. return ok
  1718. }
  1719. // Error returns the error message
  1720. func (err ErrOAuthApplicationNotFound) Error() string {
  1721. return fmt.Sprintf("OAuth application not found [ID: %d]", err.ID)
  1722. }