diff --git a/src/calibre/devices/errors.py b/src/calibre/devices/errors.py index 9b8c7b9d42..d906bb86c8 100644 --- a/src/calibre/devices/errors.py +++ b/src/calibre/devices/errors.py @@ -104,3 +104,9 @@ class ControlError(ProtocolError): if self.desc: return self.desc return "Unknown control error occurred" + +class WrongDestinationError(PathError): + ''' The user chose the wrong destination to send books to, for example by + trying to send books to a non existant storage card.''' + pass + diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 759aa80bbb..600916128d 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -15,7 +15,8 @@ import os, subprocess, time, re, sys, glob from itertools import repeat from calibre.devices.interface import DevicePlugin -from calibre.devices.errors import DeviceError, FreeSpaceError +from calibre.devices.errors import (DeviceError, FreeSpaceError, + WrongDestinationError) from calibre.devices.usbms.deviceconfig import DeviceConfig from calibre.constants import iswindows, islinux, isosx, isfreebsd, plugins from calibre.utils.filenames import ascii_filename as sanitize, shorten_components_to @@ -976,9 +977,17 @@ class Device(DeviceConfig, DevicePlugin): def _sanity_check(self, on_card, files): if on_card == 'carda' and not self._card_a_prefix: - raise ValueError(_('The reader has no storage card in this slot.')) + raise WrongDestinationError(_( + 'The reader has no storage card %s. You may have changed ' + 'the default send to device action. Right click on the send ' + 'to device button and reset the default action to be ' + '"Send to main memory".')%'A') elif on_card == 'cardb' and not self._card_b_prefix: - raise ValueError(_('The reader has no storage card in this slot.')) + raise WrongDestinationError(_( + 'The reader has no storage card %s. You may have changed ' + 'the default send to device action. Right click on the send ' + 'to device button and reset the default action to be ' + '"Send to main memory".')%'B') elif on_card and on_card not in ('carda', 'cardb'): raise DeviceError(_('Selected slot: %s is not supported.') % on_card) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 4ecf18f836..a029e0be8f 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -23,7 +23,7 @@ from calibre.gui2 import (config, error_dialog, Dispatcher, dynamic, from calibre.ebooks.metadata import authors_to_string from calibre import preferred_encoding, prints, force_unicode, as_unicode from calibre.utils.filenames import ascii_filename -from calibre.devices.errors import FreeSpaceError +from calibre.devices.errors import FreeSpaceError, WrongDestinationError from calibre.devices.apple.driver import ITUNES_ASYNC from calibre.devices.folder_device.driver import FOLDER_DEVICE from calibre.devices.bambook.driver import BAMBOOK, BAMBOOKWifi @@ -1450,6 +1450,9 @@ class DeviceMixin(object): # {{{ 'is no more free space available ')+where+ '

\n'%(titles,)) d.exec_() + elif isinstance(job.exception, WrongDestinationError): + error_dialog(self, _('Incorrect destination'), + unicode(job.exception), show=True) else: self.device_job_exception(job) return