1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-09-28 15:08:47 +00:00

Better Errors for fs API

This commit is contained in:
Wilma456 2017-07-15 16:09:29 +02:00
parent 94d701b1f7
commit 239a2f0d25
4 changed files with 36 additions and 36 deletions

View File

@ -94,7 +94,7 @@ public class ComboMount implements IMount
} }
else else
{ {
throw new IOException( "Not a directory" ); throw new IOException( "Not a directory (" + path + ")" );
} }
} }
@ -109,7 +109,7 @@ public class ComboMount implements IMount
return part.getSize( path ); return part.getSize( path );
} }
} }
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
@Nonnull @Nonnull
@ -124,6 +124,6 @@ public class ComboMount implements IMount
return part.openForRead( path ); return part.openForRead( path );
} }
} }
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
} }

View File

@ -129,7 +129,7 @@ public class FileMount implements IWritableMount
{ {
if( path.length() != 0 ) if( path.length() != 0 )
{ {
throw new IOException( "Not a directory" ); throw new IOException( "Not a directory (" + path + ")" );
} }
} }
else else
@ -148,7 +148,7 @@ public class FileMount implements IWritableMount
} }
else else
{ {
throw new IOException( "Not a directory" ); throw new IOException( "Not a directory (" + path + ")" );
} }
} }
} }
@ -178,7 +178,7 @@ public class FileMount implements IWritableMount
} }
} }
} }
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
@Nonnull @Nonnull
@ -193,7 +193,7 @@ public class FileMount implements IWritableMount
return new FileInputStream( file ); return new FileInputStream( file );
} }
} }
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
// IWritableMount implementation // IWritableMount implementation
@ -207,7 +207,7 @@ public class FileMount implements IWritableMount
{ {
if( !file.isDirectory() ) if( !file.isDirectory() )
{ {
throw new IOException( "File exists" ); throw new IOException( "File exists (" + path + ")" );
} }
} }
else else
@ -222,7 +222,7 @@ public class FileMount implements IWritableMount
if( getRemainingSpace() < dirsToCreate * MINIMUM_FILE_SIZE ) if( getRemainingSpace() < dirsToCreate * MINIMUM_FILE_SIZE )
{ {
throw new IOException( "Out of space" ); throw new IOException( "Out of space (" + path + ")" );
} }
boolean success = file.mkdirs(); boolean success = file.mkdirs();
@ -232,7 +232,7 @@ public class FileMount implements IWritableMount
} }
else else
{ {
throw new IOException( "Access denied" ); throw new IOException( "Access denied (" + path + ")" );
} }
} }
} }
@ -242,7 +242,7 @@ public class FileMount implements IWritableMount
{ {
if( path.length() == 0 ) if( path.length() == 0 )
{ {
throw new IOException( "Access denied" ); throw new IOException( "Access denied (" + path + ")" );
} }
if( created() ) if( created() )
@ -276,7 +276,7 @@ public class FileMount implements IWritableMount
} }
else else
{ {
throw new IOException( "Access denied" ); throw new IOException( "Access denied (" + path + ")" );
} }
} }
@ -288,7 +288,7 @@ public class FileMount implements IWritableMount
File file = getRealPath( path ); File file = getRealPath( path );
if( file.exists() && file.isDirectory() ) if( file.exists() && file.isDirectory() )
{ {
throw new IOException( "Cannot write to directory" ); throw new IOException( "Cannot write to directory (" + path + ")" );
} }
else else
{ {
@ -296,7 +296,7 @@ public class FileMount implements IWritableMount
{ {
if( getRemainingSpace() < MINIMUM_FILE_SIZE ) if( getRemainingSpace() < MINIMUM_FILE_SIZE )
{ {
throw new IOException( "Out of space" ); throw new IOException( "Out of space (" + path + ")" );
} }
else else
{ {
@ -321,11 +321,11 @@ public class FileMount implements IWritableMount
File file = getRealPath( path ); File file = getRealPath( path );
if( !file.exists() ) if( !file.exists() )
{ {
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
else if( file.isDirectory() ) else if( file.isDirectory() )
{ {
throw new IOException( "Cannot write to directory" ); throw new IOException( "Cannot write to directory (" + path + ")" );
} }
else else
{ {
@ -334,7 +334,7 @@ public class FileMount implements IWritableMount
} }
else else
{ {
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
} }
@ -361,7 +361,7 @@ public class FileMount implements IWritableMount
boolean success = m_rootPath.mkdirs(); boolean success = m_rootPath.mkdirs();
if( !success ) if( !success )
{ {
throw new IOException( "Access denied" ); throw new IOException( "Access denied (" + path + ")" );
} }
} }
} }

View File

@ -110,7 +110,7 @@ public class FileSystem
} }
else else
{ {
throw new FileSystemException( "Not a directory" ); throw new FileSystemException( "Not a directory (" + path + ")" );
} }
} }
catch( IOException e ) catch( IOException e )
@ -137,7 +137,7 @@ public class FileSystem
} }
else else
{ {
throw new FileSystemException( "No such file" ); throw new FileSystemException( "No such file (" + path + ")" );
} }
} }
catch( IOException e ) catch( IOException e )
@ -157,7 +157,7 @@ public class FileSystem
} }
else else
{ {
throw new FileSystemException( "No such file" ); throw new FileSystemException( "No such file (" + path + ")" );
} }
} }
catch( IOException e ) catch( IOException e )
@ -172,7 +172,7 @@ public class FileSystem
{ {
if( m_writableMount == null ) if( m_writableMount == null )
{ {
throw new FileSystemException( "Access denied" ); throw new FileSystemException( "Access denied (" + path + ")" );
} }
try try
{ {
@ -181,7 +181,7 @@ public class FileSystem
{ {
if( !m_mount.isDirectory( path ) ) if( !m_mount.isDirectory( path ) )
{ {
throw new FileSystemException( "File exists" ); throw new FileSystemException( "File exists (" + path + ")" );
} }
} }
else else
@ -199,7 +199,7 @@ public class FileSystem
{ {
if( m_writableMount == null ) if( m_writableMount == null )
{ {
throw new FileSystemException( "Access denied" ); throw new FileSystemException( "Access denied (" + path + ")" );
} }
try try
{ {
@ -219,14 +219,14 @@ public class FileSystem
{ {
if( m_writableMount == null ) if( m_writableMount == null )
{ {
throw new FileSystemException( "Access denied" ); throw new FileSystemException( "Access denied (" + path + ")" );
} }
try try
{ {
path = toLocal( path ); path = toLocal( path );
if( m_mount.exists( path ) && m_mount.isDirectory( path ) ) if( m_mount.exists( path ) && m_mount.isDirectory( path ) )
{ {
throw new FileSystemException( "Cannot write to directory" ); throw new FileSystemException( "Cannot write to directory (" + path + ")" );
} }
else else
{ {
@ -251,7 +251,7 @@ public class FileSystem
{ {
if( m_writableMount == null ) if( m_writableMount == null )
{ {
throw new FileSystemException( "Access denied" ); throw new FileSystemException( "Access denied (" + path + ")" );
} }
try try
{ {
@ -270,7 +270,7 @@ public class FileSystem
} }
else if( m_mount.isDirectory( path ) ) else if( m_mount.isDirectory( path ) )
{ {
throw new FileSystemException( "Cannot write to directory" ); throw new FileSystemException( "Cannot write to directory (" + path + ")" );
} }
else else
{ {
@ -557,16 +557,16 @@ public class FileSystem
sourcePath = sanitizePath( sourcePath ); sourcePath = sanitizePath( sourcePath );
destPath = sanitizePath( destPath ); destPath = sanitizePath( destPath );
if( isReadOnly( destPath ) ) { if( isReadOnly( destPath ) ) {
throw new FileSystemException( "Access denied" ); throw new FileSystemException( "Access denied (" + destPath + ")" );
} }
if( !exists( sourcePath ) ) { if( !exists( sourcePath ) ) {
throw new FileSystemException( "No such file" ); throw new FileSystemException( "No such file (" + sourcePath + ")" );
} }
if( exists( destPath ) ) { if( exists( destPath ) ) {
throw new FileSystemException( "File exists" ); throw new FileSystemException( "File exists (" + destPath + ")" );
} }
if( contains( sourcePath, destPath ) ) { if( contains( sourcePath, destPath ) ) {
throw new FileSystemException( "Can't copy a directory inside itself" ); throw new FileSystemException( "Can't copy a directory inside itself (" + sourcePath + ")" );
} }
copyRecursive( sourcePath, getMount( sourcePath ), destPath, getMount( destPath ) ); copyRecursive( sourcePath, getMount( sourcePath ), destPath, getMount( destPath ) );
} }
@ -730,7 +730,7 @@ public class FileSystem
} }
if( match == null ) if( match == null )
{ {
throw new FileSystemException( "Invalid Path" ); throw new FileSystemException( "Invalid Path (" + path + ")" );
} }
return match; return match;
} }

View File

@ -203,7 +203,7 @@ public class JarMount implements IMount
} }
else else
{ {
throw new IOException( "Not a directory" ); throw new IOException( "Not a directory (" + path + ")" );
} }
} }
@ -215,7 +215,7 @@ public class JarMount implements IMount
{ {
return file.getSize(); return file.getSize();
} }
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
@Nonnull @Nonnull
@ -243,6 +243,6 @@ public class JarMount implements IMount
// treat errors as non-existance of file // treat errors as non-existance of file
} }
} }
throw new IOException( "No such file" ); throw new IOException( "No such file (" + path + ")" );
} }
} }