MatchException Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Thrown to indicate an unexpected failure in pattern matching.
[Android.Runtime.Register("java/lang/MatchException", ApiSince=36, DoNotGenerateAcw=true)]
public sealed class MatchException : Java.Lang.RuntimeException
[<Android.Runtime.Register("java/lang/MatchException", ApiSince=36, DoNotGenerateAcw=true)>]
type MatchException = class
inherit RuntimeException
- Inheritance
- Attributes
Remarks
Thrown to indicate an unexpected failure in pattern matching.
MatchException
may be thrown when an exhaustive pattern matching language construct (such as a switch
expression) encounters a value that does not match any of the specified patterns at run time, even though the construct has been deemed exhaustive. This is intentional and can arise from a number of cases:
<ul> <li>Separate compilation anomalies, where parts of the type hierarchy that the patterns reference have been changed, but the pattern matching construct has not been recompiled. For example, if a sealed interface has a different set of permitted subtypes at run time than it had at compile time, or if an enum class has a different set of enum constants at runtime than it had at compile time, or if the type hierarchy has been changed in some incompatible way between compile time and run time.</li>
<li>null
values and nested patterns involving sealed classes. If, for example, an interface I
is sealed
with two permitted subclasses A
and B
, and a record class R
has a single component of type I
, then the two record patterns R(A a)
and R(B b)
together are considered to be exhaustive for the type R
, but neither of these patterns will match against the result of new R(null)
.</li>
<li>null
values and nested record patterns. Given a record class S
with a single component of type T
, where T
is another record class with a single component of type String
, then the nested record pattern R(S(var s))
is considered exhaustive for the type R
but it does not match against the result of new R(null)
(whereas it does match against the result of new R(new S(null))
does).</li> </ul>
MatchException
may also be thrown by the process of pattern matching a value against a pattern. For example, pattern matching involving a record pattern may require accessor methods to be implicitly invoked in order to extract the component values. If any of these accessor methods throws an exception, pattern matching completes abruptly and throws MatchException
. The original exception will be set as a Throwable#getCause() cause
of the MatchException
. No Throwable#addSuppressed(java.lang.Throwable) suppressed
exceptions will be recorded.
Added in 21.
Java documentation for java.lang.MatchException
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
MatchException(String, Throwable) |
Constructs an |
Fields
is_generated | (Inherited from Throwable) |
Properties
Cause |
Returns the cause of this throwable or |
Class | (Inherited from Throwable) |
Handle |
The handle to the underlying Android instance. (Inherited from Throwable) |
JniIdentityHashCode | (Inherited from Throwable) |
JniPeerMembers | |
LocalizedMessage |
Creates a localized description of this throwable. (Inherited from Throwable) |
Message |
Returns the detail message string of this throwable. (Inherited from Throwable) |
PeerReference | (Inherited from Throwable) |
StackTrace | (Inherited from Throwable) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from RuntimeException) |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from RuntimeException) |
Methods
AddSuppressed(Throwable) |
Appends the specified exception to the exceptions that were suppressed in order to deliver this exception. (Inherited from Throwable) |
Dispose() | (Inherited from Throwable) |
Dispose(Boolean) | (Inherited from Throwable) |
FillInStackTrace() |
Fills in the execution stack trace. (Inherited from Throwable) |
GetStackTrace() |
Provides programmatic access to the stack trace information printed by
|
GetSuppressed() |
Returns an array containing all of the exceptions that were
suppressed, typically by the |
InitCause(Throwable) |
Initializes the cause of this throwable to the specified value. (Inherited from Throwable) |
PrintStackTrace() |
Prints this throwable and its backtrace to the standard error stream. (Inherited from Throwable) |
PrintStackTrace(PrintStream) |
Prints this throwable and its backtrace to the specified print stream. (Inherited from Throwable) |
PrintStackTrace(PrintWriter) |
Prints this throwable and its backtrace to the specified print writer. (Inherited from Throwable) |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Throwable) |
SetStackTrace(StackTraceElement[]) |
Sets the stack trace elements that will be returned by
|
ToString() | (Inherited from Throwable) |
UnregisterFromRuntime() | (Inherited from Throwable) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Throwable) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Throwable) |
IJavaPeerable.Finalized() | (Inherited from Throwable) |
IJavaPeerable.JniManagedPeerState | (Inherited from Throwable) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Throwable) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Throwable) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Throwable) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |