mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-25 03:32:16 +00:00
Updated error handling
This commit is contained in:
parent
4a4cf12bca
commit
12cafe7ff5
@ -20,6 +20,7 @@
|
|||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "xm6.h"
|
#include "xm6.h"
|
||||||
#include "controllers/sasidev_ctrl.h"
|
#include "controllers/sasidev_ctrl.h"
|
||||||
|
#include "exceptions.h"
|
||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -1750,10 +1751,12 @@ int Disk::GetSectorSizeInBytes() const
|
|||||||
return disk.size ? 1 << disk.size : 0;
|
return disk.size ? 1 << disk.size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Disk::SetSectorSizeInBytes(int size, bool sasi)
|
void Disk::SetSectorSizeInBytes(int size, bool sasi)
|
||||||
{
|
{
|
||||||
if (sasi && size != 256 && size != 1024) {
|
if (sasi && size != 256 && size != 1024) {
|
||||||
return false;
|
stringstream error;
|
||||||
|
error << "Invalid sector size of " << size << " bytes";
|
||||||
|
throw io_exception(error.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (size) {
|
switch (size) {
|
||||||
@ -1778,12 +1781,11 @@ bool Disk::SetSectorSizeInBytes(int size, bool sasi)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
stringstream error;
|
||||||
disk.size = 9;
|
error << "Invalid sector size of " << size << " bytes";
|
||||||
|
throw io_exception(error.str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Disk::GetSectorSize() const
|
int Disk::GetSectorSize() const
|
||||||
|
@ -124,7 +124,7 @@ public:
|
|||||||
int SelectCheck10(const DWORD *cdb); // SELECT(10) check
|
int SelectCheck10(const DWORD *cdb); // SELECT(10) check
|
||||||
|
|
||||||
int GetSectorSizeInBytes() const;
|
int GetSectorSizeInBytes() const;
|
||||||
bool SetSectorSizeInBytes(int, bool);
|
void SetSectorSizeInBytes(int, bool);
|
||||||
int GetSectorSize() const;
|
int GetSectorSize() const;
|
||||||
bool IsSectorSizeConfigurable() const;
|
bool IsSectorSizeConfigurable() const;
|
||||||
vector<int> GetSectorSizes() const;
|
vector<int> GetSectorSizes() const;
|
||||||
|
@ -70,12 +70,7 @@ void SASIHD::Open(const Filepath& path)
|
|||||||
fio.Close();
|
fio.Close();
|
||||||
|
|
||||||
// Sector size (default 256 bytes) and number of blocks
|
// Sector size (default 256 bytes) and number of blocks
|
||||||
if (!SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 256, true)) {
|
SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 256, true);
|
||||||
stringstream error;
|
|
||||||
error << "Invalid sector size " << GetConfiguredSectorSize();
|
|
||||||
throw io_exception(error.str());
|
|
||||||
|
|
||||||
}
|
|
||||||
SetBlockCount((DWORD)(size >> GetSectorSize()));
|
SetBlockCount((DWORD)(size >> GetSectorSize()));
|
||||||
|
|
||||||
#if defined(REMOVE_FIXED_SASIHD_SIZE)
|
#if defined(REMOVE_FIXED_SASIHD_SIZE)
|
||||||
|
@ -71,12 +71,7 @@ void SCSIHD::Open(const Filepath& path)
|
|||||||
fio.Close();
|
fio.Close();
|
||||||
|
|
||||||
// Sector size (default 512 bytes) and number of blocks
|
// Sector size (default 512 bytes) and number of blocks
|
||||||
if (!SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 512, false)) {
|
SetSectorSizeInBytes(GetConfiguredSectorSize() ? GetConfiguredSectorSize() : 512, false);
|
||||||
stringstream error;
|
|
||||||
error << "Invalid sector size " << GetConfiguredSectorSize();
|
|
||||||
throw io_exception(error.str());
|
|
||||||
|
|
||||||
}
|
|
||||||
SetBlockCount((DWORD)(size >> GetSectorSize()));
|
SetBlockCount((DWORD)(size >> GetSectorSize()));
|
||||||
|
|
||||||
// File size must be a multiple of the sector size
|
// File size must be a multiple of the sector size
|
||||||
|
Loading…
Reference in New Issue
Block a user