blob: 89a0b25450e676625c155d385bc346787fbb1919 [file] [log] [blame]
andrewsbrown43b96302015-03-17 21:51:43 +01001/*
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 Afanasyeva8bc0d82016-01-25 17:25:30 -080014
andrewsbrown43b96302015-03-17 21:51:43 +010015package com.intel.jndn.management;
16
Alexander Afanasyev499aced2016-02-17 19:32:37 -080017import net.named_data.jndn.ControlResponse;
18
andrewsbrown43b96302015-03-17 21:51:43 +010019
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 */
27public class ManagementException extends Exception {
andrewsbrown43b96302015-03-17 21:51:43 +010028 /**
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080029 * Constructor from the message
andrewsbrown43b96302015-03-17 21:51:43 +010030 */
31 public ManagementException(String message) {
32 super(message);
33 }
34
35 /**
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080036 * Constructor from the message and the cause
andrewsbrown43b96302015-03-17 21:51:43 +010037 */
38 public ManagementException(String message, Throwable cause) {
39 super(message, cause);
40 }
41
42 /**
43 * Parse an NFD response to create a ManagementException.
andrewsbrown43b96302015-03-17 21:51:43 +010044 */
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}