string mountpoint = attachPoint().asString();
bool mountsucceeded = false;
int count = 0;
+ MediaMountException merr;
string options = _url.getQueryParam("mountoptions");
if (options.empty())
));
}
}
+ catch (const MediaMountException &e)
+ {
+ merr = e;
+ removeAttachPoint();
+ ZYPP_CAUGHT(e);
+ }
catch (const MediaException & excpt_r)
{
removeAttachPoint();
if (!mountsucceeded)
{
_lastdev = -1;
- ZYPP_THROW(MediaMountException(_url.asString(), mountpoint, "Mounting media failed"));
+
+ if( !merr.mountOutput().empty())
+ {
+ ZYPP_THROW(MediaMountException(merr.mountError(),
+ _url.asString(),
+ mountpoint,
+ merr.mountOutput()));
+ }
+ else
+ {
+ ZYPP_THROW(MediaMountException("Mounting media failed",
+ _url.asString(), mountpoint));
+ }
}
DBG << _lastdev << " " << count << endl;
}
std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
{
- return str << "Failed to mount " << _source << " on " << _target
- << " : " << _error << endl;
+ str << "Failed to mount " << _source << " on " << _target;
+ if( !_cmdout.empty())
+ str << ": " << _error << " (" << _cmdout << ")" << endl;
+ else
+ str << ": " << _error << endl;
+ return str;
}
std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
class MediaMountException : public MediaException
{
public:
+ MediaMountException()
+ : MediaException( "Media Mount Exception" )
+ {}
+
/** Ctor taking message.
* Use \ref ZYPP_THROW to throw exceptions.
*/
MediaMountException( const std::string & error_r,
const std::string & source_r,
- const std::string & target_r )
+ const std::string & target_r,
+ const std::string & cmdout_r="")
: MediaException()
, _error(error_r)
, _source(source_r)
, _target(target_r)
+ , _cmdout(cmdout_r)
{}
/** Dtor. */
virtual ~MediaMountException() throw() {};
+
+ const std::string & mountError() const
+ { return _error; }
+ const std::string & mountSource() const
+ { return _source; }
+ const std::string & mountTarget() const
+ { return _target; }
+ const std::string & mountOutput() const
+ { return _cmdout; }
+
protected:
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
std::string _error;
std::string _source;
std::string _target;
+ std::string _cmdout;
};
class MediaUnmountException : public MediaException
{
ZYPP_CAUGHT(excpt_r);
}
- ZYPP_THROW(MediaMountException(isofile.asString(), mountpoint,
- "Unable to verify that the media was mounted"
+ ZYPP_THROW(MediaMountException(
+ "Unable to verify that the media was mounted",
+ isofile.asString(), mountpoint
));
}
}
if ( process == NULL )
{
- ZYPP_THROW(MediaMountException(source, target, "Mounting media failed"));
+ ZYPP_THROW(MediaMountException("Mounting media failed", source, target));
}
string value;
{
err = "Nfs path is not a directory";
}
+ else
+ {
+ err = "Unable to find directory on the media";
+ }
}
output = process->receiveLine();
if ( err != "" ) {
WAR << "mount " << source << " " << target << ": " << err << endl;
- ZYPP_THROW(MediaMountException(source, target, err));
+ ZYPP_THROW(MediaMountException(err, source, target, value));
} else {
MIL << "mounted " << source << " " << target << endl;
}