IOException: The IOException heierarchy.

Description Usage Arguments Value Functions See Also Examples

View source: R/IOExceptions.R

Description

IOExceptions and their sub-classes are Exceptions that describe problems encoutered reading or writting to a file, network socket, console, connection, etc. Subclasses extended the specificity of the IOException and can include data elements. See Exception. These exceptions are intended to be signaled, i.e. with stop and exist both to provide pre-defined error messages and so that handlers in try/catch blocks have latitude to choose what granularity of exception to catch.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
IOException(message = "*", call = NULL, package = packageName(), ...)

FileSystemException(message = "*", call = NULL, package = packageName(),
  ...)

PathException(path, message = "*", call = NULL, package = packageName(),
  ...)

FileException(path, message = "*", call = NULL, package = packageName(),
  ...)

DirectoryException(path, message = "*", call = NULL,
  package = packageName(), ...)

LinkException(path, target, message = "*", call = NULL,
  package = packageName(), ...)

NoSuchLinkTargetException(path, target, message = "*", call = NULL,
  package = packageName(), ...)

NoSuchFileException(path, message = "*", call = NULL,
  package = packageName(), ...)

NoSuchDirectoryException(path, message = "*", call = NULL,
  package = packageName(), ...)

NoSuchLinkException(path, target = NA, message = "*", call = NULL,
  package = packageName(), ...)

FileExistsException(path, message = "*", call = NULL,
  package = packageName(), ...)

DirectoryExistsException(path, message = "*", call = NULL,
  package = packageName(), ...)

LinkExistsException(path, target, message = "*", call = NULL,
  package = packageName(), ...)

Arguments

message

The message associated with the exception, for reading by humans. The default message is usually good enough, but can be overriden through this parameter if needed. When constructed inside packages, the message displayed will have the name of the package prepended as '[package] message' due to conditionMessage being over-ridden for Exception subclasses.

call

The call or call stack associated with the exception. By default this is NULL as IOExceptions are usually environment problems. Can be overriden to provide the sys.calls call stack or a single sys.call.

package

The package where this exception is generated. May be NULL when exceptions are generated and signaled from interactive or script level code and not from a package. Attempts to guess the package by default. Will usually include the package in the dispalyed message.

...

Additional arguments defining arg= value data to include in the Exception (accessible as list elements, but preferably by S3 accessor functions).

path

The path associated with an exception, as a one element character vector This is required for a PathException or sub-class, but may be NULL or NA. Accessible via the the exceptionPath S3 accessor.

target

The target associated with a problematic file system link. This is required for a LinkException or sub-class, but may be NULL or NA. Accessible via the the exceptionTarget S3 accessor

Value

An IOException or descendant describing some problematic event involving a file system, a network socket, etc. Always has or extends class c( "IOException", "Exception", "condition" ).

Functions

See Also

condition, conditionMessage(), conditionCall, Exception, exceptionPackage

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ioEx <- IOException()
conditionMessage(ioEx)
conditionCall(ioEx)
exceptionPackage(ioEx)

ioEx <- IOException( "Including the call stack", call=sys.calls() )
ioEx <- IOException( "Lying about the package", package="NotMine" )
ioEx <- IOException( "Extra data included", x=1, y=list(A=1, B="two"), path="../" )
x <- ioEx$x
y <- ioEx$y
path <- exceptionPath(ioEx)
path == ioEx$path

pEx <- PathException( "/some/path" )
thePath <- exceptionPath(pEx)

## Not run: 
  wantToCreate <- "theFile"
  if ( file.exists( wantToCreate )) {
     if (is.dir) { stop( DirectoryExists( wantToCreate )) }
     else { stop( FileExists( wantToCreate )) }
  }

## End(Not run)

jefferys/Exception documentation built on May 19, 2019, 3:59 a.m.