All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anrisoftware.fractions.calculator.parser.ArgsException Maven / Gradle / Ivy

/*
 * Copyright 2013-2015 Erwin Müller 
 *
 * This file is part of fractions-calculator-cli.
 *
 * fractions-calculator-cli is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * fractions-calculator-cli is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * fractions-calculator-cli. If not, see .
 */
package com.anrisoftware.fractions.calculator.parser;

import java.util.Map;

import com.anrisoftware.globalpom.exceptions.Context;

/**
 * Signaling errors while parsing command line arguments.
 * 
 * @author Erwin Mueller, [email protected]
 * @since 2.0
 */
@SuppressWarnings("serial")
public class ArgsException extends Exception {

	private final Context context;

	/**
	 * @see Exception#Exception(String, Throwable)
	 */
	public ArgsException(String message, Throwable cause) {
		super(message, cause);
		this.context = new Context(this);
	}

	/**
	 * @see Exception#Exception(String)
	 */
	public ArgsException(String message) {
		super(message);
		this.context = new Context(this);
	}

	/**
	 * @see Exception#Exception(String, Throwable)
	 */
	public ArgsException(Object message, Throwable cause) {
		super(message.toString(), cause);
		this.context = new Context(this);
	}

	/**
	 * @see Exception#Exception(String)
	 */
	public ArgsException(Object message) {
		super(message.toString());
		this.context = new Context(this);
	}

	/**
	 * @see Context#addContext(String, Object)
	 */
	public ArgsException add(String name, Object value) {
		context.addContext(name, value);
		return this;
	}

	/**
	 * @see Context#addContext(String, Object)
	 */
	public ArgsException add(Object name, Object value) {
		context.addContext(name.toString(), value);
		return this;
	}

	/**
	 * @see Context#getContext()
	 */
	public Map getContext() {
		return context.getContext();
	}

	@Override
	public String toString() {
		return context.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy