blob: 69e209abb8c963ff5dda1a659d3a87a1d300bd58 [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
17import com.intel.jndn.management.types.ControlResponse;
andrewsbrown43b96302015-03-17 21:51:43 +010018
19/**
20 * Represent a failure to correctly manage the NDN Forwarding Daemon (NFD).
21 * Inspect this object with getCause() to see why the management operation
22 * failed.
23 *
24 * @author Andrew Brown <andrew.brown@intel.com>
25 */
26public class ManagementException extends Exception {
andrewsbrown43b96302015-03-17 21:51:43 +010027 /**
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080028 * Constructor from the message
andrewsbrown43b96302015-03-17 21:51:43 +010029 */
30 public ManagementException(String message) {
31 super(message);
32 }
33
34 /**
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080035 * Constructor from the message and the cause
andrewsbrown43b96302015-03-17 21:51:43 +010036 */
37 public ManagementException(String message, Throwable cause) {
38 super(message, cause);
39 }
40
41 /**
42 * Parse an NFD response to create a ManagementException.
andrewsbrown43b96302015-03-17 21:51:43 +010043 */
44 public static ManagementException fromResponse(ControlResponse response) {
45 String message = "Action failed, forwarder returned: " + response.getStatusCode() + " " + response.getStatusText();
46 return new ManagementException(message);
47 }
48}