UnsupportedException

Summary

The exception to be thrown if the host environment does not support a necessary feature.

Description

UnsupportedException should be thrown if the host environment does not support a required or necessary feature.

An example would be a library that depends on the DOM (Document Object Model) API of the web browser. When the library is used outside the web browser, the DOM API functions are not available. Thus, the library may choose to throw UnsupportedException.

Difference from UnimplementedException

The key difference between UnimplementedException and UnsupportedException is that the former specifies an interface method is not implemented yet, while the latter specifies it's not possible to implement the interface method. All methods of an interface must be implemented, and UnimplementedException and UnsupportedException provide conveniences for dealing with interfaces.

Examples

Basic Usage
1
2
3
4
5
6
7
8
import System;
external XMLHttpRequest;
 
if (typeof XMLHttpRequest != "function") {
    throw new System.Exceptions.UnsupportedException(
        "AJAX (XMLHttpRequest) is not supported in this environment."
    );
}

Methods

Share

HTML | BBCode | Direct Link