/*
* This file is part of laurelin/shared
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
use serde::Serialize;
use thiserror::Error;
#[doc = "API errors are in the 1XXXX range"]
#[derive(Debug, Serialize, Error)]
pub enum APIError {
// general errors
#[doc = "Should never be used, but still exists just in case"]
#[error("undefined error")]
Undefined = 10000,
#[doc = "Authorization doesn't meet requirements"]
#[error("not authorized")]
NotAuthorized = 10001,
#[doc = "Authorization is missing from the request"]
#[error("missing authorization")]
MissingAuthorization = 10002,
// user related errors
#[doc = "User does not exist in the database"]
#[error("user not found")]
UserNotFound = 11000,
#[doc = "Invalid credentials were passed"]
#[error("invalid credentials")]
UserInvalidCredentials = 11001,
// login errors
#[doc = ""]
#[error("invalid email")]
UserEmailInvalid = 11100,
#[doc = ""]
#[error("username should not be shorter than 3 characters")]
UserUsernameTooShort = 11101,
#[doc = ""]
#[error("password should not be shorter than 8 characters")]
UserPasswordTooShort = 11102,
#[doc = ""]
#[error("user creation failed")]
UserCreationFailed = 11103,
}