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.

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