How to write custom exception with user defined fields?

This might be an easy thing but I am just confused a bit. How to write a custom exception with user defined fields. Lets take an example: public class MyException extends Exception { public