andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * jndn-management |
| 3 | * Copyright (c) 2015, Intel Corporation. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU Lesser General Public License, |
| 7 | * version 3, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT ANY |
| 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 12 | * more details. |
| 13 | */ |
Alexander Afanasyev | a8bc0d8 | 2016-01-25 17:25:30 -0800 | [diff] [blame] | 14 | |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 15 | package com.intel.jndn.management; |
| 16 | |
Alexander Afanasyev | 499aced | 2016-02-17 19:32:37 -0800 | [diff] [blame^] | 17 | import net.named_data.jndn.ControlResponse; |
| 18 | |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * Represent a failure to correctly manage the NDN Forwarding Daemon (NFD). |
| 22 | * Inspect this object with getCause() to see why the management operation |
| 23 | * failed. |
| 24 | * |
| 25 | * @author Andrew Brown <andrew.brown@intel.com> |
| 26 | */ |
| 27 | public class ManagementException extends Exception { |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 28 | /** |
Alexander Afanasyev | a8bc0d8 | 2016-01-25 17:25:30 -0800 | [diff] [blame] | 29 | * Constructor from the message |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 30 | */ |
| 31 | public ManagementException(String message) { |
| 32 | super(message); |
| 33 | } |
| 34 | |
| 35 | /** |
Alexander Afanasyev | a8bc0d8 | 2016-01-25 17:25:30 -0800 | [diff] [blame] | 36 | * Constructor from the message and the cause |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 37 | */ |
| 38 | public ManagementException(String message, Throwable cause) { |
| 39 | super(message, cause); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Parse an NFD response to create a ManagementException. |
andrewsbrown | 43b9630 | 2015-03-17 21:51:43 +0100 | [diff] [blame] | 44 | */ |
| 45 | public static ManagementException fromResponse(ControlResponse response) { |
| 46 | String message = "Action failed, forwarder returned: " + response.getStatusCode() + " " + response.getStatusText(); |
| 47 | return new ManagementException(message); |
| 48 | } |
| 49 | } |