DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 977e440bf1876853ee128c287bd2f5c02cce82f4 deck-builder/api/apierror/apierror.go -rw-r--r-- 2.4 KiB
977e440bJonni Liljamo wip(client): log ui 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * This file is part of laurelin_api
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

package apierror

// general errors
var (
	Placeholder     APIError = APIError{1000, "Placeholder", "placeholder"}
	InvalidInput    APIError = APIError{1001, "InvalidInput", "invalid input"}
	NotAuthorized   APIError = APIError{1002, "NotAuthorized", "not authorized"}
	MissingAuth     APIError = APIError{1003, "MissingAuthorization", "missing authorization"}
	GenericJWTError APIError = APIError{1004, "GenericJWTError", ""}
)

// user related errors
var (
	UserNotFound APIError = APIError{2000, "UserNotFound", "user not found"}
	InvalidCred  APIError = APIError{2001, "InvalidCred", "invalid credentials"}
	NewJWTError  APIError = APIError{2003, "NewJWTError", "jwt creation error"}
	// login errors
	EmailInvalid       APIError = APIError{2100, "EmailInvalid", "invalid email address"}
	UsernameTooShort   APIError = APIError{2101, "UsernameTooShort", "username should not be shroter than 3 characters"}
	PasswordTooShort   APIError = APIError{2102, "PasswordTooShort", "password should not be shorter than 8 characters"}
	PasswordHashFailed APIError = APIError{2103, "PasswordHashFailed", "password hash failed"}
	UserCreationFailed APIError = APIError{2104, "UserCreationFailed", "user creation failed"}
)

// game related errors
var (
	GameNotFound         APIError = APIError{3000, "GameNotFound", "game not found"}
	GameCreationFailed   APIError = APIError{3001, "GameCreationFailed", "game creation failed"}
	GetAllFormingFailed  APIError = APIError{3002, "GetAllFormingFailed", "failed to get all forming games"}
	GameStatePatchFailed APIError = APIError{3003, "GameStatePatchFailed", "failed to patch game state"}
	NoGamesForUser       APIError = APIError{3004, "NoGamesForUser", "no games found for user"}
	GameNotForming       APIError = APIError{3005, "GameNotForming", "game is not forming"}
	CannotJoinOwnGame    APIError = APIError{3006, "CannotJoinOwnGame", "can not join own game"}
	GameFull             APIError = APIError{3007, "GameFull", "game is full"}
)

// action related errors
var (
	ActionCreationFailed APIError = APIError{4000, "ActionCreationFailed", "action creation failed"}
)

type APIError struct {
	ID          uint16 `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}