1. /*
  2. * @(#)file SnmpStatusException.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 4.9
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. *
  10. */
  11. package com.sun.jmx.snmp;
  12. // "@(#)SnmpStatusException.java 3.2 98/11/05 SMI"
  13. /**
  14. * Reports an error which occurred during a get/set operation on a mib node.
  15. *
  16. * This exception includes a status error code as defined in the SNMP protocol.
  17. *
  18. * <p><b>This API is a Sun Microsystems internal API and is subject
  19. * to change without notice.</b></p>
  20. * @version 3.2 11/05/98
  21. * @author Sun Microsystems, Inc
  22. */
  23. public class SnmpStatusException extends Exception implements SnmpDefinitions {
  24. /**
  25. * Error code as defined in RFC 1448 for: <CODE>noSuchName</CODE>.
  26. */
  27. public static final int noSuchName = 2 ;
  28. /**
  29. * Error code as defined in RFC 1448 for: <CODE>badValue</CODE>.
  30. */
  31. public static final int badValue = 3 ;
  32. /**
  33. * Error code as defined in RFC 1448 for: <CODE>readOnly</CODE>.
  34. */
  35. public static final int readOnly = 4 ;
  36. /**
  37. * Error code as defined in RFC 1448 for: <CODE>noAccess</CODE>.
  38. */
  39. public static final int noAccess = 6 ;
  40. /**
  41. * Error code for reporting a no such instance error.
  42. */
  43. public static final int noSuchInstance = 0xE0;
  44. /**
  45. * Error code for reporting a no such object error.
  46. */
  47. public static final int noSuchObject = 0xE1;
  48. /**
  49. * Constructs a new <CODE>SnmpStatusException</CODE> with the specified status error.
  50. * @param status The error status.
  51. */
  52. public SnmpStatusException(int status) {
  53. errorStatus = status ;
  54. }
  55. /**
  56. * Constructs a new <CODE>SnmpStatusException</CODE> with the specified status error and status index.
  57. * @param status The error status.
  58. * @param index The error index.
  59. */
  60. public SnmpStatusException(int status, int index) {
  61. errorStatus = status ;
  62. errorIndex = index ;
  63. }
  64. /**
  65. * Constructs a new <CODE>SnmpStatusException</CODE> with an error message.
  66. * The error status is set to 0 (noError) and the index to -1.
  67. * @param s The error message.
  68. */
  69. public SnmpStatusException(String s) {
  70. super(s);
  71. }
  72. /**
  73. * Constructs a new <CODE>SnmpStatusException</CODE> with an error index.
  74. * @param x The original <CODE>SnmpStatusException</CODE>.
  75. * @param index The error index.
  76. */
  77. public SnmpStatusException(SnmpStatusException x, int index) {
  78. super(x.getMessage());
  79. errorStatus= x.errorStatus;
  80. errorIndex= index;
  81. }
  82. /**
  83. * Return the error status.
  84. * @return The error status.
  85. */
  86. public int getStatus() {
  87. return errorStatus ;
  88. }
  89. /**
  90. * Returns the index of the error.
  91. * A value of -1 means that the index is not known/applicable.
  92. * @return The error index.
  93. */
  94. public int getErrorIndex() {
  95. return errorIndex;
  96. }
  97. // PRIVATE VARIABLES
  98. //--------------------
  99. /**
  100. * Status of the error.
  101. * @serial
  102. */
  103. private int errorStatus = 0 ;
  104. /**
  105. * Index of the error.
  106. * If different from -1, indicates the index where the error occurs.
  107. * @serial
  108. */
  109. private int errorIndex= -1;
  110. }