package org.opennms.mock.snmp.responder;

import org.snmp4j.smi.Variable;

/**
 * Throws an SNMP error with a status code matching
 * the requested instance.
 *
 * See org.snmp4j.mp.SnmpConstants.SNMP_ERROR_* for known error codes.
 *
 * @author jwhite
 */
public class Error implements DynamicVariable {

    @Override
    public Variable getVariableForOID(String oidStr) throws SnmpErrorStatusException {
        String[] oids = oidStr.split("\\.");
        Integer instance = Integer.parseInt(oids[oids.length-1]);
        throw new SnmpErrorStatusException(instance);
    }

}

@@ -1,8 +1,1215 @@
+/*******************************************************************************%0A * This file is part of OpenNMS(R).%0A *%0A * Copyright (C) 2017-2017 The OpenNMS Group, Inc.%0A * OpenNMS(R) is Copyright (C) 1999-2017 The OpenNMS Group, Inc.%0A *%0A * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.%0A *%0A * OpenNMS(R) is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as published%0A * by the Free Software Foundation, either version 3 of the License,%0A * or (at your option) any later version.%0A *%0A * OpenNMS(R) is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with OpenNMS(R).  If not, see:%0A *      http://www.gnu.org/licenses/%0A *%0A * For more information contact:%0A *     OpenNMS(R) Licensing %3Clicense@opennms.org%3E%0A *     http://www.opennms.org/%0A *     http://www.opennms.com/%0A *******************************************************************************/%0A%0A
 package 

add missing copyright header