added exception class and type pattern matching code