001/*
002 * Copyright 2015-2018 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.dnssec;
012
013import org.minidns.dnsmessage.Question;
014import org.minidns.record.Data;
015import org.minidns.record.Record;
016
017import java.util.List;
018
019public class DnssecValidationFailedException extends RuntimeException {
020    private static final long serialVersionUID = 5413184667629832742L;
021
022    public DnssecValidationFailedException(Question question, String reason) {
023        super("Validation of request to " + question + " failed: " + reason);
024    }
025
026    public DnssecValidationFailedException(String message) {
027        super(message);
028    }
029
030    public DnssecValidationFailedException(String message, Throwable cause) {
031        super(message, cause);
032    }
033
034    public DnssecValidationFailedException(Record<? extends Data> record, String reason) {
035        super("Validation of record " + record + " failed: " + reason);
036    }
037
038    public DnssecValidationFailedException(List<Record<? extends Data>> records, String reason) {
039        super("Validation of " + records.size() + " " + records.get(0).type + " record" + (records.size() > 1 ? "s" : "") + " failed: " + reason);
040    }
041}