customerrors

package
v0.0.0-...-1f82a06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BadRequest = &CustomError{
		Message: "The request body is invalid. Please check the request body and try again.",
		Code:    "ERR-001",
	}
	UsernameTaken = &CustomError{
		Message: "The username is already taken. Please try another username.",
		Code:    "ERR-002",
	}
	EmailTaken = &CustomError{
		Message: "The email is already taken. Please try another email.",
		Code:    "ERR-003",
	}
	UserNotFound = &CustomError{
		Message: "The user was not found. Please check the username and try again.",
		Code:    "ERR-004",
	}
	UserNotActivated = &CustomError{
		Message: "The user is not activated. Please activate the user and try again.",
		Code:    "ERR-005",
	}
	ActivationTokenExpired = &CustomError{
		Message: "The token has expired. Please check your mail for a new token and try again.",
		Code:    "ERR-006",
	}
	InvalidToken = &CustomError{
		Message: "The token is invalid. Please check the token and try again.",
		Code:    "ERR-007",
	}
	InvalidCredentials = &CustomError{
		Message: "The credentials are invalid. Please check the credentials and try again.",
		Code:    "ERR-008",
	}
	InternalServerError = &CustomError{
		Message: "An internal server error occurred. Please try again later.",
		Code:    "ERR-009",
	}
	DatabaseError = &CustomError{
		Message: "A database error occurred. Please try again later.",
		Code:    "ERR-010",
	}
	EmailUnreachable = &CustomError{
		Message: "The email is unreachable. Please check the email and try again.",
		Code:    "ERR-011",
	}
	EmailNotSent = &CustomError{
		Message: "The email could not be sent. Please try again later.",
		Code:    "ERR-012",
	}
	UserAlreadyActivated = &CustomError{
		Message: "The user is already activated. Please login to your account.",
		Code:    "ERR-013",
	}
	UserUnauthorized = &CustomError{
		Message: "The request is unauthorized. Please login to your account.",
		Code:    "ERR-014",
	}
	SubscriptionNotFound = &CustomError{
		Message: "The subscription was not found. Please check the username and try again.",
		Code:    "ERR-015",
	}
	SubscriptionAlreadyExists = &CustomError{
		Message: "The subscription already exists. Please check the username and try again.",
		Code:    "ERR-016",
	}
	SelfFollow = &CustomError{
		Message: "You cannot follow yourself. Please check the username and try again.",
		Code:    "ERR-017",
	}
	SubscriptionDeleteNotAuthorized = &CustomError{
		Message: "You can only delete your own subscriptions.",
		Code:    "ERR-018",
	}
	PostDeleteForbidden = &CustomError{
		Message: "You can only delete your own posts.",
		Code:    "ERR-019",
	}
	PostNotFound = &CustomError{
		Message: "The post was not found. Please check the post ID and try again.",
		Code:    "ERR-020",
	}
	FileNotFound = &CustomError{
		Message: "file not found: to be defined",
		Code:    "",
	}
	FileTooLarge = &CustomError{
		Message: "file too large: to be defined",
		Code:    "",
	}
)

Custom error constants

Functions

This section is empty.

Types

type CustomError

type CustomError struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

CustomError can be used to create custom customerrors

func (*CustomError) Error

func (e *CustomError) Error() string

Error function to implement the error interface

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Message string `json:"message"`
		Code    string `json:"code"`
	} `json:"error"`
}

ErrorResponse is used for testing to see if the right custom error was returned

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL