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.

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