summaryrefslogtreecommitdiff
path: root/shared/src/main/java/kz/ilotterytea/frogartha/exceptions/PlayerKickException.java
blob: 4eaf38920b7629fb3f0c375d7553d8e436910230 (plain)
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
package kz.ilotterytea.frogartha.exceptions;

import com.github.czyzby.websocket.serialization.SerializationException;
import com.github.czyzby.websocket.serialization.Transferable;
import com.github.czyzby.websocket.serialization.impl.Deserializer;
import com.github.czyzby.websocket.serialization.impl.Serializer;

public class PlayerKickException extends RuntimeException implements Transferable<PlayerKickException> {
    public PlayerKickException() {
    }

    private PlayerKickException(String message) {
        super(message);
    }

    public static PlayerKickException loggedIn() {
        return new PlayerKickException("You logged in from another location");
    }

    public static PlayerKickException internalServerError() {
        return new PlayerKickException("Internal Server Error");
    }

    @Override
    public void serialize(Serializer serializer) throws SerializationException {
        serializer.serializeString(getMessage());
    }

    @Override
    public PlayerKickException deserialize(Deserializer deserializer) throws SerializationException {
        return new PlayerKickException(deserializer.deserializeString());
    }
}