use crate::records::error_converter::ErrorConverter;
use crate::records::type_error::TypeError;
use crate::records::type_error_to_string_options::TypeErrorToStringOptions;
use crate::type_aliases::type_error_data::TypeErrorData;
use alloc::string::String;

/// C++ `std::string toString(const TypeError& error, TypeErrorToStringOptions options)`.
pub fn to_string_type_error_type_error_to_string_options(
    error: &TypeError,
    options: TypeErrorToStringOptions,
) -> String {
    let converter = ErrorConverter::new(options.file_resolver);
    match &error.data {
        TypeErrorData::TypeMismatch(e) => converter.operator_call_40(e),
        TypeErrorData::UnknownSymbol(e) => converter.operator_call_45(e),
        TypeErrorData::UnknownProperty(e) => converter.operator_call_43(e),
        TypeErrorData::NotATable(e) => converter.operator_call_34(e),
        TypeErrorData::CannotExtendTable(e) => converter.operator_call_15(e),
        TypeErrorData::CannotCompareUnrelatedTypes(e) => converter.operator_call_14(e),
        TypeErrorData::OnlyTablesCanHaveMethods(e) => converter.operator_call_36(e),
        TypeErrorData::DuplicateTypeDefinition(e) => converter.operator_call_22(e),
        TypeErrorData::CountMismatch(e) => converter.operator_call_19(e),
        TypeErrorData::FunctionDoesNotTakeSelf(e) => converter.operator_call_24(e),
        TypeErrorData::FunctionRequiresSelf(e) => converter.operator_call_26(e),
        TypeErrorData::OccursCheckFailed(e) => converter.operator_call_35(e),
        TypeErrorData::UnknownRequire(e) => converter.operator_call_44(e),
        TypeErrorData::IncorrectGenericParameterCount(e) => converter.operator_call_29(e),
        TypeErrorData::SyntaxError(e) => converter.operator_call_39(e),
        TypeErrorData::CodeTooComplex(e) => converter.operator_call_17(e),
        TypeErrorData::UnificationTooComplex(e) => converter.operator_call_41(e),
        TypeErrorData::UnknownPropButFoundLikeProp(e) => converter.operator_call_42(e),
        TypeErrorData::GenericError(e) => converter.operator_call_27(e),
        TypeErrorData::InternalError(e) => converter.operator_call_30(e),
        TypeErrorData::ConstraintSolvingIncompleteError(e) => converter.operator_call_18(e),
        TypeErrorData::CannotCallNonFunction(e) => converter.operator_call_13(e),
        TypeErrorData::ExtraInformation(e) => converter.operator_call_23(e),
        TypeErrorData::DeprecatedApiUsed(e) => converter.operator_call_20(e),
        TypeErrorData::ModuleHasCyclicDependency(e) => converter.operator_call_33(e),
        TypeErrorData::IllegalRequire(e) => converter.operator_call_28(e),
        TypeErrorData::FunctionExitsWithoutReturning(e) => converter.operator_call_25(e),
        TypeErrorData::DuplicateGenericParameter(e) => converter.operator_call_21(e),
        TypeErrorData::CannotAssignToNever(e) => converter.operator_call_3(e),
        TypeErrorData::CannotInferBinaryOperation(e) => converter.operator_call_16(e),
        TypeErrorData::MissingProperties(e) => converter.operator_call_31(e),
        TypeErrorData::SwappedGenericTypeParameter(e) => converter.operator_call_38(e),
        TypeErrorData::OptionalValueAccess(e) => converter.operator_call_37(e),
        TypeErrorData::MissingUnionProperty(e) => converter.operator_call_32(e),
        TypeErrorData::TypesAreUnrelated(e) => converter.operator_call_55(e),
        TypeErrorData::NormalizationTooComplex(e) => converter.operator_call_48(e),
        TypeErrorData::TypePackMismatch(e) => converter.operator_call_54(e),
        TypeErrorData::DynamicPropertyLookupOnExternTypesUnsafe(e) => converter.operator_call_7(e),
        TypeErrorData::UninhabitedTypeFunction(e) => converter.operator_call_60(e),
        TypeErrorData::UninhabitedTypePackFunction(e) => converter.operator_call_61(e),
        TypeErrorData::WhereClauseNeeded(e) => converter.operator_call_63(e),
        TypeErrorData::PackWhereClauseNeeded(e) => converter.operator_call_49(e),
        TypeErrorData::CheckedFunctionCallError(e) => converter.operator_call_5(e),
        TypeErrorData::NonStrictFunctionDefinitionError(e) => converter.operator_call_47(e),
        TypeErrorData::PropertyAccessViolation(e) => converter.operator_call_50(e),
        TypeErrorData::CheckedFunctionIncorrectArgs(e) => converter.operator_call_6(e),
        TypeErrorData::UnexpectedTypeInSubtyping(e) => converter.operator_call_58(e),
        TypeErrorData::UnexpectedTypePackInSubtyping(e) => converter.operator_call_59(e),
        TypeErrorData::ExplicitFunctionAnnotationRecommended(e) => converter.operator_call_8(e),
        TypeErrorData::UserDefinedTypeFunctionError(e) => converter.operator_call_62(e),
        TypeErrorData::BuiltInTypeFunctionError(e) => converter.operator_call_2(e),
        TypeErrorData::ReservedIdentifier(e) => converter.operator_call_52(e),
        TypeErrorData::UnexpectedArrayLikeTableItem(e) => converter.operator_call_57(e),
        TypeErrorData::CannotCheckDynamicStringFormatCalls(e) => converter.operator_call_4(e),
        TypeErrorData::GenericTypeCountMismatch(e) => converter.operator_call_10(e),
        TypeErrorData::GenericTypePackCountMismatch(e) => converter.operator_call_11(e),
        TypeErrorData::MultipleNonviableOverloads(e) => converter.operator_call_46(e),
        TypeErrorData::RecursiveRestraintViolation(e) => converter.operator_call_51(e),
        TypeErrorData::GenericBoundsMismatch(e) => converter.operator_call_9(e),
        TypeErrorData::UnappliedTypeFunction(e) => converter.operator_call_56(e),
        TypeErrorData::InstantiateGenericsOnNonFunction(e) => converter.operator_call_12(e),
        TypeErrorData::TypeInstantiationCountMismatch(e) => converter.operator_call_53(e),
        TypeErrorData::AmbiguousFunctionCall(e) => converter.operator_call(e),
    }
}
