Stay organized with collections
Save and categorize content based on your preferences.
ErrnoException
class ErrnoException : Exception
A checked exception thrown when Os
methods fail. This exception contains the native errno value, for comparison against the constants in OsConstants
, should sophisticated callers need to adjust their behavior based on the exact failure.
Summary
Public constructors |
Constructs an instance with the given function name and errno value.
|
Constructs an instance with the given function name, errno value, and cause.
|
Properties |
Int |
The errno value, for comparison with the E constants in OsConstants .
|
String? |
Converts the stashed function name and errno value to a human-readable string.
|
Public constructors
ErrnoException
ErrnoException(
functionName: String!,
errno: Int)
Constructs an instance with the given function name and errno value.
ErrnoException
ErrnoException(
functionName: String!,
errno: Int,
cause: Throwable!)
Constructs an instance with the given function name, errno value, and cause.
Public methods
rethrowAsIOException
fun rethrowAsIOException(): IOException
Throws an IOException
with a message based on getMessage()
and with this instance as the cause.
This method always terminates by throwing the exception. Callers can write throw e.rethrowAsIOException()
to make that clear to the compiler.
rethrowAsSocketException
fun rethrowAsSocketException(): SocketException
Throws a SocketException
with a message based on getMessage()
and with this instance as the cause.
This method always terminates by throwing the exception. Callers can write throw e.rethrowAsIOException()
to make that clear to the compiler.
Properties
errno
val errno: Int
The errno value, for comparison with the E
constants in OsConstants
.
message
val message: String?
Converts the stashed function name and errno value to a human-readable string. We do this here rather than in the constructor so that callers only pay for this if they need it.
Return |
String? |
the detail message string of this Throwable instance (which may be null ). |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# ErrnoException\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nErrnoException\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/system/ErrnoException \"View this page in Java\") \n\n```\nclass ErrnoException : Exception\n```\n\n|---|---|---|------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) |||\n| | ↳ | [java.lang.Exception](../../java/lang/Exception.html#) ||\n| | | ↳ | [android.system.ErrnoException](#) |\n\nA checked exception thrown when [Os](/reference/kotlin/android/system/Os) methods fail. This exception contains the native errno value, for comparison against the constants in [OsConstants](/reference/kotlin/android/system/OsConstants), should sophisticated callers need to adjust their behavior based on the exact failure.\n\nSummary\n-------\n\n| Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [ErrnoException](#ErrnoException(kotlin.String,%20kotlin.Int))`(`functionName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `errno:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs an instance with the given function name and errno value. |\n| [ErrnoException](#ErrnoException(kotlin.String,%20kotlin.Int,%20kotlin.Throwable))`(`functionName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `errno:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `cause:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`)` Constructs an instance with the given function name, errno value, and cause. |\n\n| Public methods ||\n|---------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [IOException](../../java/io/IOException.html#) | [rethrowAsIOException](#rethrowAsIOException())`()` Throws an [IOException](../../java/io/IOException.html#) with a message based on [getMessage()](#message:kotlin.String) and with this instance as the cause. |\n| [SocketException](../../java/net/SocketException.html#) | [rethrowAsSocketException](#rethrowAsSocketException())`()` Throws a [SocketException](../../java/net/SocketException.html#) with a message based on [getMessage()](#message:kotlin.String) and with this instance as the cause. |\n\n| Properties ||\n|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [errno](#errno:kotlin.Int) The errno value, for comparison with the `E` constants in [OsConstants](/reference/kotlin/android/system/OsConstants). |\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | [message](#message:kotlin.String) Converts the stashed function name and errno value to a human-readable string. |\n\nPublic constructors\n-------------------\n\n### ErrnoException\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nErrnoException(\n functionName: String!, \n errno: Int)\n```\n\nConstructs an instance with the given function name and errno value. \n\n### ErrnoException\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nErrnoException(\n functionName: String!, \n errno: Int, \n cause: Throwable!)\n```\n\nConstructs an instance with the given function name, errno value, and cause.\n\nPublic methods\n--------------\n\n### rethrowAsIOException\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun rethrowAsIOException(): IOException\n```\n\nThrows an [IOException](../../java/io/IOException.html#) with a message based on [getMessage()](#message:kotlin.String) and with this instance as the cause.\n\nThis method always terminates by throwing the exception. Callers can write `throw e.rethrowAsIOException()` to make that clear to the compiler.\n\n| Return ||\n|------------------------------------------------|------------------------------|\n| [IOException](../../java/io/IOException.html#) | This value cannot be `null`. |\n\n### rethrowAsSocketException\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun rethrowAsSocketException(): SocketException\n```\n\nThrows a [SocketException](../../java/net/SocketException.html#) with a message based on [getMessage()](#message:kotlin.String) and with this instance as the cause.\n\nThis method always terminates by throwing the exception. Callers can write `throw e.rethrowAsIOException()` to make that clear to the compiler.\n\n| Return ||\n|---------------------------------------------------------|------------------------------|\n| [SocketException](../../java/net/SocketException.html#) | This value cannot be `null`. |\n\nProperties\n----------\n\n### errno\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval errno: Int\n```\n\nThe errno value, for comparison with the `E` constants in [OsConstants](/reference/kotlin/android/system/OsConstants). \n\n### message\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval message: String?\n```\n\nConverts the stashed function name and errno value to a human-readable string. We do this here rather than in the constructor so that callers only pay for this if they need it.\n\n| Return ||\n|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | the detail message string of this `Throwable` instance (which may be `null`). |"]]