/**
 * Copyright © 2023 Nevis Security AG. All rights reserved.
 */

import { type FidoErrorCodeType } from './FidoErrorCodeType';

/**
 * Error class indicating that a problem during a FIDO UAF operation occurred.
 *
 * @group Errors
 * @category Common
 */
export class FidoErrorCode {
	/**
	 * The underlying FIDO UAF error type.
	 */
	type: FidoErrorCodeType;

	/**
	 * The description of the error.
	 *
	 * > [!NOTE]
	 * > Displaying the error description directly to the end user is not recommended.
	 * > It is advisable to handle errors in a more appropriate manner, such as providing translations
	 * > for all supported languages and simplifying the error message to ensure it is understandable
	 * > and actionable for the end-users.
	 *
	 * This is not a localized message and is targeted to developers in the context
	 * of debugging/problem analysis.
	 */
	description: string;

	/**
	 * Default constructor for {@link FidoErrorCode}.
	 *
	 * @param type the underlying FIDO UAF error type.
	 * @param description the description of the error.
	 */
	constructor(type: FidoErrorCodeType, description: string) {
		this.type = type;
		this.description = description;
	}
}
