A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
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.
 
 
 
 
 

55 lines
3.0 KiB

  1. /*
  2. * Copyright © 2018 A Bunch Tell LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package writefreely
  11. import (
  12. "github.com/writeas/impart"
  13. "net/http"
  14. )
  15. // Commonly returned HTTP errors
  16. var (
  17. ErrBadFormData = impart.HTTPError{http.StatusBadRequest, "Expected valid form data."}
  18. ErrBadJSON = impart.HTTPError{http.StatusBadRequest, "Expected valid JSON object."}
  19. ErrBadJSONArray = impart.HTTPError{http.StatusBadRequest, "Expected valid JSON array."}
  20. ErrBadAccessToken = impart.HTTPError{http.StatusUnauthorized, "Invalid access token."}
  21. ErrNoAccessToken = impart.HTTPError{http.StatusBadRequest, "Authorization token required."}
  22. ErrNotLoggedIn = impart.HTTPError{http.StatusUnauthorized, "Not logged in."}
  23. ErrForbiddenCollection = impart.HTTPError{http.StatusForbidden, "You don't have permission to add to this collection."}
  24. ErrForbiddenEditPost = impart.HTTPError{http.StatusForbidden, "You don't have permission to update this post."}
  25. ErrUnauthorizedEditPost = impart.HTTPError{http.StatusUnauthorized, "Invalid editing credentials."}
  26. ErrUnauthorizedGeneral = impart.HTTPError{http.StatusUnauthorized, "You don't have permission to do that."}
  27. ErrBadRequestedType = impart.HTTPError{http.StatusNotAcceptable, "Bad requested Content-Type."}
  28. ErrCollectionUnauthorizedRead = impart.HTTPError{http.StatusUnauthorized, "You don't have permission to access this collection."}
  29. ErrNoPublishableContent = impart.HTTPError{http.StatusBadRequest, "Supply something to publish."}
  30. ErrInternalGeneral = impart.HTTPError{http.StatusInternalServerError, "The humans messed something up. They've been notified."}
  31. ErrInternalCookieSession = impart.HTTPError{http.StatusInternalServerError, "Could not get cookie session."}
  32. ErrCollectionNotFound = impart.HTTPError{http.StatusNotFound, "Collection doesn't exist."}
  33. ErrCollectionGone = impart.HTTPError{http.StatusGone, "This blog was unpublished."}
  34. ErrCollectionPageNotFound = impart.HTTPError{http.StatusNotFound, "Collection page doesn't exist."}
  35. ErrPostNotFound = impart.HTTPError{Status: http.StatusNotFound, Message: "Post not found."}
  36. ErrPostBanned = impart.HTTPError{Status: http.StatusGone, Message: "Post removed."}
  37. ErrPostUnpublished = impart.HTTPError{Status: http.StatusGone, Message: "Post unpublished by author."}
  38. ErrPostFetchError = impart.HTTPError{Status: http.StatusInternalServerError, Message: "We encountered an error getting the post. The humans have been alerted."}
  39. ErrUserNotFound = impart.HTTPError{http.StatusNotFound, "User doesn't exist."}
  40. ErrUserNotFoundEmail = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."}
  41. )
  42. // Post operation errors
  43. var (
  44. ErrPostNoUpdatableVals = impart.HTTPError{http.StatusBadRequest, "Supply some properties to update."}
  45. )