001/* 002 * This file is part of OCaml-Java runtime. 003 * Copyright (C) 2007-2013 Xavier Clerc. 004 * 005 * OCaml-Java runtime is free software; you can redistribute it and/or modify 006 * it under the terms of the GNU Lesser General Public License as published by 007 * the Free Software Foundation; either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * OCaml-Java runtime is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.ocamljava.runtime.wrappers; 020 021import org.ocamljava.runtime.kernel.FailException; import org.ocamljava.runtime.kernel.Fail; 022 023/** 024 * The {@code OCamlInvalidArgumentException} class is the Java counterpart of 025 * the {@code Invalid_argument} OCaml exception. 026 * 027 * @author <a href="mailto:xclerc@ocamljava.org">Xavier Clerc</a> 028 * @version 2.0 029 * @since 2.0 030 */ 031public final class OCamlInvalidArgumentException extends OCamlException { 032 033 /** Serialization UID. */ 034 static final long serialVersionUID = -6533756367998228103L; 035 036 /** Exception parameter. */ 037 private final String parameter; 038 039 /** 040 * Constructs a new instance. 041 * @param s exception parameter - should not be {@code null} 042 */ 043 public OCamlInvalidArgumentException(final String s) { 044 super(Fail.createWithString(OCamlException.getTag("Invalid_argument"), s)); 045 assert s != null : "null s"; 046 this.parameter = s; 047 } // end constructor(String) 048 049 /** 050 * Constructs a new instance based on the passed exception. 051 * @param fe original OCaml exception - should not be {@code null} 052 */ 053 public OCamlInvalidArgumentException(final FailException fe) { 054 super(fe); 055 this.parameter = fe.getValue().get1().asString(); 056 } // end constructor(FailException) 057 058 /** 059 * Returns exception parameter. 060 * @return exception parameter 061 */ 062 public String getParameter() { 063 return this.parameter; 064 } // end method 'getParameter()' 065 066} // end class 'OCamlInvalidArgumentException'