@classmethod
def to_string(cls, error_code):
    """Returns the string message for the given ``error_code``.

        Args:
          cls (JlinkGlobalErrors): the ``JLinkGlobalErrors`` class
          error_code (int): error code to convert

        Returns:
          An error string corresponding to the error code.

        Raises:
          ValueError: if the error code is invalid.
        """
    if error_code == cls.EMU_NO_CONNECTION:
        return 'No connection to emulator.'
    elif error_code == cls.EMU_COMM_ERROR:
        return 'Emulator connection error.'
    elif error_code == cls.DLL_NOT_OPEN:
        return "DLL has not been opened.  Did you call '.connect()'?"
    elif error_code == cls.VCC_FAILURE:
        return 'Target system has no power.'
    elif error_code == cls.INVALID_HANDLE:
        return 'Given file / memory handle is invalid.'
    elif error_code == cls.NO_CPU_FOUND:
        return 'Could not find supported CPU.'
    elif error_code == cls.EMU_FEATURE_UNSUPPORTED:
        return 'Emulator does not support the selected feature.'
    elif error_code == cls.EMU_NO_MEMORY:
        return 'Emulator out of memory.'
    elif error_code == cls.TIF_STATUS_ERROR:
        return 'Target interface error.'
    elif error_code == cls.FLASH_PROG_COMPARE_FAILED:
        return 'Programmed data differs from source data.'
    elif error_code == cls.FLASH_PROG_PROGRAM_FAILED:
        return 'Programming error occured.'
    elif error_code == cls.FLASH_PROG_VERIFY_FAILED:
        return 'Error while verifying programmed data.'
    elif error_code == cls.OPEN_FILE_FAILED:
        return 'Specified file could not be opened.'
    elif error_code == cls.UNKNOWN_FILE_FORMAT:
        return 'File format of selected file is not supported.'
    elif error_code == cls.WRITE_TARGET_MEMORY_FAILED:
        return 'Could not write target memory.'
    elif error_code == cls.DEVICE_FEATURE_NOT_SUPPORTED:
        return 'Feature not supported by connected device.'
    elif error_code == cls.WRONG_USER_CONFIG:
        return 'User configured DLL parameters incorrectly.'
    elif error_code == cls.NO_TARGET_DEVICE_SELECTED:
        return 'User did not specify core to connect to.'
    elif error_code == cls.CPU_IN_LOW_POWER_MODE:
        return 'Target CPU is in low power mode.'
    elif error_code == cls.UNSPECIFIED_ERROR:
        return 'Unspecified error.'
    raise ValueError('Invalid error code: %d' % error_code)
