1package org.bouncycastle.asn1;
2
3/**
4 * Exception thrown when correctly encoded, but unexpected data is found in a stream while building an object.
5 */
6public class ASN1ParsingException
7    extends IllegalStateException
8{
9    private Throwable cause;
10
11    /**
12     * Base constructor
13     *
14     * @param message a message concerning the exception.
15     */
16    public ASN1ParsingException(String message)
17    {
18        super(message);
19    }
20
21    /**
22     * Constructor when this exception is due to another one.
23     *
24     * @param message a message concerning the exception.
25     * @param cause the exception that caused this exception to be thrown.
26     */
27    public ASN1ParsingException(String message, Throwable cause)
28    {
29        super(message);
30        this.cause = cause;
31    }
32
33    /**
34     * Return the underlying cause of this exception, if any.
35     *
36     * @return the exception causing this one, null if there isn't one.
37     */
38    public Throwable getCause()
39    {
40        return cause;
41    }
42}
43