You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.go 62KB

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