Adding the image fullpathname to all DiskExceptions. This will normalize the User Warnings, as also will make easier to feed error reports to an eventual First Aid tool
This commit is contained in:
parent
d20056380e
commit
86b53fea37
|
@ -38,11 +38,11 @@ public class DiskCorruptException extends DiskException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public Kind kind;
|
public final Kind kind;
|
||||||
final public Object offender;
|
public final Object offender;
|
||||||
|
|
||||||
private DiskCorruptException(final String description) {
|
private DiskCorruptException(final String description, final String imagepath) {
|
||||||
super(description);
|
super(description, imagepath);
|
||||||
this.kind = null;
|
this.kind = null;
|
||||||
this.offender = null;
|
this.offender = null;
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ public class DiskCorruptException extends DiskException {
|
||||||
/**
|
/**
|
||||||
* Constructor for DiskFullException.
|
* Constructor for DiskFullException.
|
||||||
*/
|
*/
|
||||||
public DiskCorruptException(final Kind kind, final Object offender) {
|
public DiskCorruptException(final String imagepath, final Kind kind, final Object offender) {
|
||||||
super(kind.toString());
|
super(kind.toString(), imagepath);
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.offender = offender;
|
this.offender = offender;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,13 @@ public abstract class DiskException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
||||||
|
|
||||||
|
public final String imagepath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for DiskException.
|
* Constructor for DiskException.
|
||||||
*/
|
*/
|
||||||
public DiskException(String description) {
|
public DiskException(final String description, final String imagepath) {
|
||||||
super(description);
|
super(description);
|
||||||
|
this.imagepath = imagepath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class DiskFullException extends DiskException {
|
||||||
/**
|
/**
|
||||||
* Constructor for DiskFullException.
|
* Constructor for DiskFullException.
|
||||||
*/
|
*/
|
||||||
public DiskFullException(String description) {
|
public DiskFullException(final String description, final String imagepath) {
|
||||||
super(description);
|
super(description, imagepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,7 +407,9 @@ public class CpmFormatDisk extends FormattedDisk {
|
||||||
* @see com.webcodepro.applecommander.storage.DirectoryEntry#createFile()
|
* @see com.webcodepro.applecommander.storage.DirectoryEntry#createFile()
|
||||||
*/
|
*/
|
||||||
public FileEntry createFile() throws DiskFullException {
|
public FileEntry createFile() throws DiskFullException {
|
||||||
throw new DiskFullException(textBundle.get("FileCreationNotSupported")); //$NON-NLS-1$
|
throw new DiskFullException(
|
||||||
|
textBundle.get("FileCreationNotSupported") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class DosFormatDisk extends FormattedDisk {
|
||||||
|
|
||||||
// Prevents a recursive catalog crawling.
|
// Prevents a recursive catalog crawling.
|
||||||
final DosSectorAddress address = new DosSectorAddress(track, sector);
|
final DosSectorAddress address = new DosSectorAddress(track, sector);
|
||||||
if ( visits.contains(address)) throw new DiskCorruptException(DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, address);
|
if ( visits.contains(address)) throw new DiskCorruptException(this.getFilename(), DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, address);
|
||||||
else visits.add(address);
|
else visits.add(address);
|
||||||
|
|
||||||
byte[] catalogSector = readSector(track, sector);
|
byte[] catalogSector = readSector(track, sector);
|
||||||
|
@ -189,7 +189,9 @@ public class DosFormatDisk extends FormattedDisk {
|
||||||
track = catalogSector[1];
|
track = catalogSector[1];
|
||||||
sector = catalogSector[2];
|
sector = catalogSector[2];
|
||||||
}
|
}
|
||||||
throw new DiskFullException(textBundle.get("DosFormatDisk.NoMoreSpaceError")); //$NON-NLS-1$
|
throw new DiskFullException(
|
||||||
|
textBundle.get("DosFormatDisk.NoMoreSpaceError") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,7 +474,8 @@ public class DosFormatDisk extends FormattedDisk {
|
||||||
if (numberOfSectors > getFreeSectors() + fileEntry.getSectorsUsed()) {
|
if (numberOfSectors > getFreeSectors() + fileEntry.getSectorsUsed()) {
|
||||||
throw new DiskFullException(
|
throw new DiskFullException(
|
||||||
textBundle.format("DosFormatDisk.NotEnoughSectorsError", //$NON-NLS-1$
|
textBundle.format("DosFormatDisk.NotEnoughSectorsError", //$NON-NLS-1$
|
||||||
numberOfSectors, getFreeSectors()));
|
numberOfSectors, getFreeSectors())
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
// free "old" data and just rewrite stuff...
|
// free "old" data and just rewrite stuff...
|
||||||
freeSectors(fileEntry);
|
freeSectors(fileEntry);
|
||||||
|
|
|
@ -172,7 +172,9 @@ public class GutenbergFormatDisk extends FormattedDisk {
|
||||||
track = catalogSector[1];
|
track = catalogSector[1];
|
||||||
sector = catalogSector[2];
|
sector = catalogSector[2];
|
||||||
}
|
}
|
||||||
throw new DiskFullException(textBundle.get("DosFormatDisk.NoMoreSpaceError")); //$NON-NLS-1$
|
throw new DiskFullException(
|
||||||
|
textBundle.get("DosFormatDisk.NoMoreSpaceError") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -436,7 +438,8 @@ public class GutenbergFormatDisk extends FormattedDisk {
|
||||||
if (numberOfSectors > getFreeSectors() + fileEntry.getSectorsUsed()) {
|
if (numberOfSectors > getFreeSectors() + fileEntry.getSectorsUsed()) {
|
||||||
throw new DiskFullException(
|
throw new DiskFullException(
|
||||||
textBundle.format("DosFormatDisk.NotEnoughSectorsError", //$NON-NLS-1$
|
textBundle.format("DosFormatDisk.NotEnoughSectorsError", //$NON-NLS-1$
|
||||||
numberOfSectors, getFreeSectors()));
|
numberOfSectors, getFreeSectors())
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
// free "old" data and just rewrite stuff...
|
// free "old" data and just rewrite stuff...
|
||||||
// freeSectors(fileEntry); (not going to work...)
|
// freeSectors(fileEntry); (not going to work...)
|
||||||
|
|
|
@ -351,7 +351,7 @@ public class PascalFileEntry implements FileEntry {
|
||||||
volEntry.setFileCount(count - 2);
|
volEntry.setFileCount(count - 2);
|
||||||
dir.set(0, volEntry);
|
dir.set(0, volEntry);
|
||||||
disk.putDirectory(dir);
|
disk.putDirectory(dir);
|
||||||
throw new DiskFullException(s);
|
throw new DiskFullException(s, this.disk.getFilename());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,9 @@ public class PascalFormatDisk extends FormattedDisk {
|
||||||
putDirectory(dir);
|
putDirectory(dir);
|
||||||
return entry;
|
return entry;
|
||||||
} else {
|
} else {
|
||||||
throw new DiskFullException(textBundle.get("PascalFormatDisk.DiskFull")); //$NON-NLS-1$
|
throw new DiskFullException(
|
||||||
|
textBundle.get("PascalFormatDisk.DiskFull") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ProdosDiskSizeDoesNotMatchException extends DiskFullException {
|
||||||
/**
|
/**
|
||||||
* Constructor for ProdosDiskSizeDoesNotMatchException.
|
* Constructor for ProdosDiskSizeDoesNotMatchException.
|
||||||
*/
|
*/
|
||||||
public ProdosDiskSizeDoesNotMatchException(String description) {
|
public ProdosDiskSizeDoesNotMatchException(String description, final String imagepath) {
|
||||||
super(description);
|
super(description, imagepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
}
|
}
|
||||||
blockNumber = nextBlockNumber;
|
blockNumber = nextBlockNumber;
|
||||||
}
|
}
|
||||||
throw new DiskFullException(textBundle.get("ProdosFormatDisk.UnableToAllocateSpaceError")); //$NON-NLS-1$
|
throw new DiskFullException(textBundle.get("ProdosFormatDisk.UnableToAllocateSpaceError"), this.getFilename()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +278,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
final Set<Integer> visits = new HashSet<>();
|
final Set<Integer> visits = new HashSet<>();
|
||||||
while (blockNumber != 0) {
|
while (blockNumber != 0) {
|
||||||
// Prevents a recursive catalog crawling.
|
// Prevents a recursive catalog crawling.
|
||||||
if ( visits.contains(blockNumber)) throw new DiskCorruptException(DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, new ProdosBlockAddress(blockNumber));
|
if ( visits.contains(blockNumber)) throw new DiskCorruptException(this.getFilename(), DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, new ProdosBlockAddress(blockNumber));
|
||||||
else visits.add(blockNumber);
|
else visits.add(blockNumber);
|
||||||
|
|
||||||
byte[] block = readBlock(blockNumber);
|
byte[] block = readBlock(blockNumber);
|
||||||
|
@ -656,7 +656,8 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) {
|
if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) {
|
||||||
throw new DiskFullException(textBundle.
|
throw new DiskFullException(textBundle.
|
||||||
format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$
|
format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$
|
||||||
numberOfBlocks, getFreeBlocks()));
|
numberOfBlocks, getFreeBlocks())
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
// free "old" data and just rewrite stuff...
|
// free "old" data and just rewrite stuff...
|
||||||
freeBlocks(fileEntry);
|
freeBlocks(fileEntry);
|
||||||
|
@ -761,7 +762,8 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) {
|
if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) {
|
||||||
throw new DiskFullException(textBundle.
|
throw new DiskFullException(textBundle.
|
||||||
format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$
|
format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$
|
||||||
numberOfBlocks, getFreeBlocks()));
|
numberOfBlocks, getFreeBlocks())
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
// free "old" data and just rewrite stuff...
|
// free "old" data and just rewrite stuff...
|
||||||
freeBlocks(fileEntry);
|
freeBlocks(fileEntry);
|
||||||
|
@ -928,7 +930,8 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) {
|
if (numberOfBlocks > getFreeBlocks() + fileEntry.getBlocksUsed()) {
|
||||||
throw new DiskFullException(textBundle.
|
throw new DiskFullException(textBundle.
|
||||||
format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$
|
format("ProdosFormatDisk.NotEnoughSpaceOnDiskError", //$NON-NLS-1$
|
||||||
numberOfBlocks, getFreeBlocks()));
|
numberOfBlocks, getFreeBlocks())
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
// free "old" data and just rewrite stuff...
|
// free "old" data and just rewrite stuff...
|
||||||
freeBlocks(fileEntry);
|
freeBlocks(fileEntry);
|
||||||
|
@ -1069,12 +1072,14 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
throw new ProdosDiskSizeDoesNotMatchException(
|
throw new ProdosDiskSizeDoesNotMatchException(
|
||||||
textBundle.get("ProdosFormatDisk.ProdosDiskSizeDoesNotMatchError")); //$NON-NLS-1$
|
textBundle.get("ProdosFormatDisk.ProdosDiskSizeDoesNotMatchError") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
block++;
|
block++;
|
||||||
}
|
}
|
||||||
throw new DiskFullException(
|
throw new DiskFullException(
|
||||||
textBundle.get("ProdosFormatDisk.NoFreeBlockAvailableError")); //$NON-NLS-1$
|
textBundle.get("ProdosFormatDisk.NoFreeBlockAvailableError") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1423,6 +1428,8 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
}
|
}
|
||||||
blockNumber = nextBlockNumber;
|
blockNumber = nextBlockNumber;
|
||||||
}
|
}
|
||||||
throw new DiskFullException(textBundle.get("ProdosFormatDisk.UnableToAllocateSpaceError")); //$NON-NLS-1$
|
throw new DiskFullException(
|
||||||
|
textBundle.get("ProdosFormatDisk.UnableToAllocateSpaceError") //$NON-NLS-1$
|
||||||
|
, this.getFilename());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class RdosFormatDisk extends FormattedDisk {
|
||||||
* Create a new FileEntry.
|
* Create a new FileEntry.
|
||||||
*/
|
*/
|
||||||
public FileEntry createFile() throws DiskFullException {
|
public FileEntry createFile() throws DiskFullException {
|
||||||
throw new DiskFullException(textBundle.get("FileCreationNotSupported")); //$NON-NLS-1$
|
throw new DiskFullException(textBundle.get("FileCreationNotSupported"), this.getFilename()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue