about summary refs log tree commit diff
path: root/BugMine.Sdk/Exceptions/BugMineException.cs
blob: 7e843b39dbf44bd0625243608388418da7911a16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System.Diagnostics.CodeAnalysis;
using LibMatrix;

namespace BugMine.Web.Classes.Exceptions;

public class BugMineException : MatrixException {
    [SetsRequiredMembers]
    public BugMineException(string errorCode, string? message = null) {
        ErrorCode = errorCode;
        Error = message ?? Message;
    }

    public sealed override string Message =>
        $"{ErrorCode}: {ErrorCode switch {
            // common
            ErrorCodes.UserNotInRoom => "User is not in the room",
            _ => base.Message
        }}";

    public new static class ErrorCodes {
        public const string UserNotInRoom = "BUGMINE_USER_NOT_IN_ROOM";
    }
}