Dart API Referencedart:ioOSError

OSError class

An OSError object holds information about an error from the operating system.

class OSError implements Error {
 /** Constant used to indicate that no OS error code is available. */
 static const int noErrorCode = -1;

 /** Creates an OSError object from a message and an errorCode. */
 const OSError([String this.message = "", int this.errorCode = noErrorCode]);

 /** Converts an OSError object to a string representation. */
 String toString() {
   StringBuffer sb = new StringBuffer();
   sb.write("OS Error");
   if (!message.isEmpty) {
     sb.write(": ");
     sb.write(message);
     if (errorCode != noErrorCode) {
       sb.write(", errno = ");
       sb.write(errorCode.toString());
     }
   } else if (errorCode != noErrorCode) {
     sb.write(": errno = ");
     sb.write(errorCode.toString());
   }
   return sb.toString();
 }

 /**
   * Error message supplied by the operating system. null if no message is
   * associated with the error.
   */
 final String message;

 /**
   * Error code supplied by the operating system. Will have the value
   * [noErrorCode] if there is no error code associated with the error.
   */
 final int errorCode;
}

Implements

Error

Static Properties

const int noErrorCode #

Constant used to indicate that no OS error code is available.

static const int noErrorCode = -1

Constructors

const OSError([String message = "", int errorCode = noErrorCode]) #

Creates an OSError object from a message and an errorCode.

const OSError([String this.message = "", int this.errorCode = noErrorCode]);

Properties

final int errorCode #

Error code supplied by the operating system. Will have the value noErrorCode if there is no error code associated with the error.

final int errorCode

final String message #

Error message supplied by the operating system. null if no message is associated with the error.

final String message

Methods

String toString() #

Converts an OSError object to a string representation.

String toString() {
 StringBuffer sb = new StringBuffer();
 sb.write("OS Error");
 if (!message.isEmpty) {
   sb.write(": ");
   sb.write(message);
   if (errorCode != noErrorCode) {
     sb.write(", errno = ");
     sb.write(errorCode.toString());
   }
 } else if (errorCode != noErrorCode) {
   sb.write(": errno = ");
   sb.write(errorCode.toString());
 }
 return sb.toString();
}