export class LogtoError extends Error {
    constructor(e: string | Error) {
        super(typeof e === 'string' ? e : e.message);
        Error.captureStackTrace(this, this.constructor);
        this.name = 'LogtoError';
        this.message = typeof e == 'string' ? e : e.message || '';
    }
}

export class UserMissingRequiredFieldsError extends LogtoError {
    constructor() {
        super('사용자 생성에 필요한 필수 정보가 누락되었습니다.');
        this.name = "UserMissingRequiredFieldsError";
    }
}

export class UserNotFoundError extends LogtoError {
    constructor(email: string, phone: string) {
        super(`이메일: ${email}, 전화번호: ${phone}로 사용자를 찾을 수 없습니다.`);
        this.name = "UserNotFoundError";
    }
}

export class MultipleUsersFoundError extends LogtoError {
    constructor(email: string, phone: string) {
        super(`이메일: ${email}, 전화번호: ${phone}로 여러 사용자가 발견되었습니다.`);
        this.name = "MultipleUsersFoundError";
    }
}

export class TokenRevocationFailedError extends LogtoError {
    constructor() {
        super('토큰 해지에 실패했습니다.');
        this.name = "TokenRevocationFailedError";
    }
}

export class AuthorizationCodeTokenFetchError extends LogtoError {
    constructor(code: string) {
        super(`인증 코드를 사용한 토큰 발급에 실패했습니다. 코드: ${code}`);
        this.name = "AuthorizationCodeTokenFetchError";
    }
}

export class SignInUriGenerationError extends LogtoError {
    constructor(signInType: string) {
        super(`로그인 URI 생성에 실패했습니다. 타입: ${signInType}`);
        this.name = "SignInUriGenerationError";
    }
}

export class SignOutUriGenerationError extends LogtoError {
    constructor() {
        super('로그아웃 URI 생성에 실패했습니다.');
        this.name = "SignOutUriGenerationError";
    }
}

export class PersonalAccessTokenFetchError extends LogtoError {
    constructor() {
        super('Personal Access Token을 사용한 액세스 토큰 발급에 실패했습니다.');
        this.name = "PersonalAccessTokenFetchError";
    }
}

