<commit_before>//
// Created by <NAME> on 2019-03-21.
// Copyright (c) 2019 Particle. All rights reserved.
//

import Foundation

enum MeshSetupErrorSeverity {
    case Error //can't continue at this point, but retrying might help
    case Fatal //can't continue and flow has to be restarted
}

enum MeshSetupFlowError: Error, CustomStringConvertible {
    //trying to perform action at the wrong time
    case IllegalOperation

    //EnsureTargetDeviceCanBeClaimed
    case UnableToGenerateClaimCode

    //ConnectToTargetDevice && ConnectToCommissionerDevice
    case DeviceTooFar
    case FailedToStartScan
    case FailedToFlashBecauseOfTimeout
    case FailedToScanBecauseOfTimeout
    case FailedToHandshakeBecauseOfTimeout
    case FailedToConnect

    case CannotAddGatewayDeviceAsJoiner

    case UnableToDownloadFirmwareBinary

    //Can happen in any step, inform user about it and repeat the step
    case BluetoothDisabled
    case BluetoothConnectionDropped

    case MeshNotSupported
    case CommissionerMeshNotSupported

    //Can happen in any step, when result != NONE and special case is not handled by onReply handler
    case BluetoothError
    case BluetoothTimeout

    //EnsureCommissionerNetworkMatches
    case CommissionerNetworkDoesNotMatch
    case WrongNetworkPassword
    case PasswordTooShort
    case WifiPasswordTooShort

    case SameDeviceScannedTwice
    case WrongTargetDeviceType
    case WrongCommissionerDeviceType

    //EnsureHasInternetAccess
    case FailedToObtainIp
    case FailedToObtainIpBoron
    case FailedToUpdateDeviceOS
    case FailedToGetDeviceInfo

    case InvalidDeviceState

    //GetNewDeviceName
    case SimBelongsToOtherAccount
    case CriticalFlowError
    case ExternalSimNotSupported
    case StickerError
    case NetworkError
    case FailedToActivateSim
    case FailedToDeactivateSim
    case FailedToChangeSimDataLimit
    case CCMissing
    case UnableToGetPricingInformation
    case UnableToPublishDeviceSetupEvent
    case UnableToGetSimStatus
    case UnableToJoinNetwork
    case UnableToJoinOldNetwork
    case UnableToRetrieveNetworks
    case UnableToLeaveNetwork
    case UnableToCreateNetwork
    case UnableToRenameDevice
    case NameTooShort
    case BoronModemError
    case NameInUse

    case DeviceIsNotAllowedToJoinNetwork
    case DeviceIsUnableToFindNetworkToJoin
    case DeviceTimeoutWhileJoiningNetwork
    case ThisDeviceIsACommissioner

    //CheckDeviceGotClaimed
    case DeviceConnectToCloudTimeout
    case DeviceGettingClaimedTimeout


    public var description: String {
        switch self {
                //unproofread
            case .CriticalFlowError : return MeshStrings.Error.CriticalFlowError.meshLocalized()
            case .SimBelongsToOtherAccount : return MeshStrings.Error.SimBelongsToOtherAccount.meshLocalized()
            case .ExternalSimNotSupported : return MeshStrings.Error.ExternalSimNotSupported.meshLocalized()
            case .StickerError : return MeshStrings.Error.StickerError.meshLocalized()
            case .NetworkError : return MeshStrings.Error.NetworkError.meshLocalized()
            case .InvalidDeviceState : return MeshStrings.Error.InvalidDeviceState.meshLocalized()
            case .NameInUse : return MeshStrings.Error.NameInUse.meshLocalized()
            case .FailedToObtainIpBoron : return MeshStrings.Error.FailedToObtainIpBoron.meshLocalized()
            case .WrongTargetDeviceType : return MeshStrings.Error.WrongTargetDeviceType.meshLocalized()
            case .WrongCommissionerDeviceType : return MeshStrings.Error.WrongCommissionerDeviceType.meshLocalized()
            case .BoronModemError : return MeshStrings.Error.BoronModemError.meshLocalized()
            case .FailedToChangeSimDataLimit : return MeshStrings.Error.FailedToChangeSimDataLimit.meshLocalized()
            case .FailedToGetDeviceInfo : return MeshStrings.Error.FailedToGetDeviceInfo.meshLocalized()
            case .FailedToFlashBecauseOfTimeout : return MeshStrings.Error.FailedToFlashBecauseOfTimeout.meshLocalized()
            case .FailedToHandshakeBecauseOfTimeout : return MeshStrings.Error.FailedToHandshakeBecauseOfTimeout.meshLocalized()

            case .MeshNotSupported : return MeshStrings.Error.FailedToHandshakeBecauseOfTimeout.meshLocalized()
            case .CommissionerMeshNotSupported : return MeshStrings.Error.FailedToHandshakeBecauseOfTimeout.meshLocalized()

                //these errors are handled instantly
            case .FailedToUpdateDeviceOS : return MeshStrings.Error.FailedToUpdateDeviceOS.meshLocalized()
            case .UnableToDownloadFirmwareBinary : return MeshStrings.Error.UnableToDownloadFirmwareBinary.meshLocalized()
            case .CannotAddGatewayDeviceAsJoiner : return MeshStrings.Error.CannotAddGatewayDeviceAsJoiner.meshLocalized()<commit_msg>fix error messages using wrong strings from json<commit_after>//
// Created by <NAME> on 2019-03-21.
// Copyright (c) 2019 Particle. All rights reserved.
//

import Foundation

enum MeshSetupErrorSeverity {
    case Error //can't continue at this point, but retrying might help
    case Fatal //can't continue and flow has to be restarted
}

enum MeshSetupFlowError: Error, CustomStringConvertible {
    //trying to perform action at the wrong time
    case IllegalOperation

    //EnsureTargetDeviceCanBeClaimed
    case UnableToGenerateClaimCode

    //ConnectToTargetDevice && ConnectToCommissionerDevice
    case DeviceTooFar
    case FailedToStartScan
    case FailedToFlashBecauseOfTimeout
    case FailedToScanBecauseOfTimeout
    case FailedToHandshakeBecauseOfTimeout
    case FailedToConnect

    case CannotAddGatewayDeviceAsJoiner

    case UnableToDownloadFirmwareBinary

    //Can happen in any step, inform user about it and repeat the step
    case BluetoothDisabled
    case BluetoothConnectionDropped

    case MeshNotSupported
    case CommissionerMeshNotSupported

    //Can happen in any step, when result != NONE and special case is not handled by onReply handler
    case BluetoothError
    case BluetoothTimeout

    //EnsureCommissionerNetworkMatches
    case CommissionerNetworkDoesNotMatch
    case WrongNetworkPassword
    case PasswordTooShort
    case WifiPasswordTooShort

    case SameDeviceScannedTwice
    case WrongTargetDeviceType
    case WrongCommissionerDeviceType

    //EnsureHasInternetAccess
    case FailedToObtainIp
    case FailedToObtainIpBoron
    case FailedToUpdateDeviceOS
    case FailedToGetDeviceInfo

    case InvalidDeviceState

    //GetNewDeviceName
    case SimBelongsToOtherAccount
    case CriticalFlowError
    case ExternalSimNotSupported
    case StickerError
    case NetworkError
    case FailedToActivateSim
    case FailedToDeactivateSim
    case FailedToChangeSimDataLimit
    case CCMissing
    case UnableToGetPricingInformation
    case UnableToPublishDeviceSetupEvent
    case UnableToGetSimStatus
    case UnableToJoinNetwork
    case UnableToJoinOldNetwork
    case UnableToRetrieveNetworks
    case UnableToLeaveNetwork
    case UnableToCreateNetwork
    case UnableToRenameDevice
    case NameTooShort
    case BoronModemError
    case NameInUse

    case DeviceIsNotAllowedToJoinNetwork
    case DeviceIsUnableToFindNetworkToJoin
    case DeviceTimeoutWhileJoiningNetwork
    case ThisDeviceIsACommissioner

    //CheckDeviceGotClaimed
    case DeviceConnectToCloudTimeout
    case DeviceGettingClaimedTimeout


    public var description: String {
        switch self {
                //unproofread
            case .CriticalFlowError : return MeshStrings.Error.CriticalFlowError.meshLocalized()
            case .SimBelongsToOtherAccount : return MeshStrings.Error.SimBelongsToOtherAccount.meshLocalized()
            case .ExternalSimNotSupported : return MeshStrings.Error.ExternalSimNotSupported.meshLocalized()
            case .StickerError : return MeshStrings.Error.StickerError.meshLocalized()
            case .NetworkError : return MeshStrings.Error.NetworkError.meshLocalized()
            case .InvalidDeviceState : return MeshStrings.Error.InvalidDeviceState.meshLocalized()
            case .NameInUse : return MeshStrings.Error.NameInUse.meshLocalized()
            case .FailedToObtainIpBoron : return MeshStrings.Error.FailedToObtainIpBoron.meshLocalized()
            case .WrongTargetDeviceType : return MeshStrings.Error.WrongTargetDeviceType.meshLocalized()
            case .WrongCommissionerDeviceType : return MeshStrings.Error.WrongCommissionerDeviceType.meshLocalized()
            case .BoronModemError : return MeshStrings.Error.BoronModemError.meshLocalized()
            case .FailedToChangeSimDataLimit : return MeshStrings.Error.FailedToChangeSimDataLimit.meshLocalized()
            case .FailedToGetDeviceInfo : return MeshStrings.Error.FailedToGetDeviceInfo.meshLocalized()
            case .FailedToFlashBecauseOfTimeout : return MeshStrings.Error.FailedToFlashBecauseOfTimeout.meshLocalized()
            case .FailedToHandshakeBecauseOfTimeout : return MeshStrings.Error.FailedToHandshakeBecauseOfTimeout.meshLocalized()

            case .MeshNotSupported : return MeshStrings.Error.MeshNotSupported.meshLocalized()
            case .CommissionerMeshNotSupported : return MeshStrings.Error.CommissionerMeshNotSupported.meshLocalized()

                //these errors are handled instantly
            case .FailedToUpdateDeviceOS : return MeshStrings.Error.FailedToUpdateDeviceOS.meshLocalized()
            case .UnableToDownloadFirmwareBinary : return MeshStrings.Error.UnableToDownloadFirmwareBinary.meshLocalized()
            case .CannotAddGatewayDeviceAsJoiner : return MeshStrings.Error.CannotAddGatewayDeviceAsJoiner.meshLocalized()
{'fraction_non_alphanumeric': 0.0418168709444845, 'fraction_numerical': 0.002471933257802039, 'mean_word_length': 3.8069306930693068, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3001903', 'n_tokens_mistral': 2597, 'n_tokens_neox': 2439, 'n_words': 584}