The OpenD Programming Language

VariantException

Thrown in three cases:

  1. An uninitialized Variant is used in any way except assignment and hasValue;
  2. A get or coerce is attempted with an incompatible target type;
  3. A comparison between Variant objects of incompatible types is attempted.
static
class VariantException : Exception {}

Members

Variables

source
TypeInfo source;

The source type in the conversion or comparison

target
TypeInfo target;

The target type in the conversion or comparison

Examples

import std.exception : assertThrown;

Variant v;

// uninitialized use
assertThrown!VariantException(v + 1);
assertThrown!VariantException(v.length);

// .get with an incompatible target type
assertThrown!VariantException(Variant("a").get!int);

// comparison between incompatible types
assertThrown!VariantException(Variant(3) < Variant("a"));

Meta