1 18 19 package com.knowgate.jcifs.netbios; 20 21 import java.io.IOException ; 22 23 public class NbtException extends IOException { 24 25 public static final int SUCCESS = 0; 27 public static final int ERR_NAM_SRVC = 0x01; 28 public static final int ERR_SSN_SRVC = 0x02; 29 30 public static final int FMT_ERR = 0x1; 32 public static final int SRV_ERR = 0x2; 33 public static final int IMP_ERR = 0x4; 34 public static final int RFS_ERR = 0x5; 35 public static final int ACT_ERR = 0x6; 36 public static final int CFT_ERR = 0x7; 37 38 public static final int CONNECTION_REFUSED = -1; 40 public static final int NOT_LISTENING_CALLED = 0x80; 41 public static final int NOT_LISTENING_CALLING = 0x81; 42 public static final int CALLED_NOT_PRESENT = 0x82; 43 public static final int NO_RESOURCES = 0x83; 44 public static final int UNSPECIFIED = 0x8F; 45 46 public int errorClass; 47 public int errorCode; 48 49 public static String getErrorString( int errorClass, int errorCode ) { 50 String result = ""; 51 switch( errorClass ) { 52 case SUCCESS: 53 result += "SUCCESS"; 54 break; 55 case ERR_NAM_SRVC: 56 result += "ERR_NAM_SRVC/"; 57 switch( errorCode ) { 58 case FMT_ERR: 59 result += "FMT_ERR: Format Error"; 60 default: 61 result += "Unknown error code: " + errorCode; 62 } 63 break; 64 case ERR_SSN_SRVC: 65 result += "ERR_SSN_SRVC/"; 66 switch( errorCode ) { 67 case CONNECTION_REFUSED: 68 result += "Connection refused"; 69 break; 70 case NOT_LISTENING_CALLED: 71 result += "Not listening on called name"; 72 break; 73 case NOT_LISTENING_CALLING: 74 result += "Not listening for calling name"; 75 break; 76 case CALLED_NOT_PRESENT: 77 result += "Called name not present"; 78 break; 79 case NO_RESOURCES: 80 result += "Called name present, but insufficient resources"; 81 break; 82 case UNSPECIFIED: 83 result += "Unspecified error"; 84 break; 85 default: 86 result += "Unknown error code: " + errorCode; 87 } 88 break; 89 default: 90 result += "unknown error class: " + errorClass; 91 } 92 return result; 93 } 94 95 public NbtException( int errorClass, int errorCode ) { 96 super( getErrorString( errorClass, errorCode )); 97 this.errorClass = errorClass; 98 this.errorCode = errorCode; 99 } 100 public String toString() { 101 return new String ( "errorClass=" + errorClass + ",errorCode=" + errorCode + ",errorString=" + getErrorString( errorClass, errorCode )); 102 } 103 } 104 | Popular Tags |