001: /* jcifs smb client library in Java
002: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.knowgate.jcifs.netbios;
020:
021: import java.io.IOException;
022:
023: public class NbtException extends IOException {
024:
025: // error classes
026: public static final int SUCCESS = 0;
027: public static final int ERR_NAM_SRVC = 0x01;
028: public static final int ERR_SSN_SRVC = 0x02;
029:
030: // name service error codes
031: public static final int FMT_ERR = 0x1;
032: public static final int SRV_ERR = 0x2;
033: public static final int IMP_ERR = 0x4;
034: public static final int RFS_ERR = 0x5;
035: public static final int ACT_ERR = 0x6;
036: public static final int CFT_ERR = 0x7;
037:
038: // session service error codes
039: public static final int CONNECTION_REFUSED = -1;
040: public static final int NOT_LISTENING_CALLED = 0x80;
041: public static final int NOT_LISTENING_CALLING = 0x81;
042: public static final int CALLED_NOT_PRESENT = 0x82;
043: public static final int NO_RESOURCES = 0x83;
044: public static final int UNSPECIFIED = 0x8F;
045:
046: public int errorClass;
047: public int errorCode;
048:
049: public static String getErrorString(int errorClass, int errorCode) {
050: String result = "";
051: switch (errorClass) {
052: case SUCCESS:
053: result += "SUCCESS";
054: break;
055: case ERR_NAM_SRVC:
056: result += "ERR_NAM_SRVC/";
057: switch (errorCode) {
058: case FMT_ERR:
059: result += "FMT_ERR: Format Error";
060: default:
061: result += "Unknown error code: " + errorCode;
062: }
063: break;
064: case ERR_SSN_SRVC:
065: result += "ERR_SSN_SRVC/";
066: switch (errorCode) {
067: case CONNECTION_REFUSED:
068: result += "Connection refused";
069: break;
070: case NOT_LISTENING_CALLED:
071: result += "Not listening on called name";
072: break;
073: case NOT_LISTENING_CALLING:
074: result += "Not listening for calling name";
075: break;
076: case CALLED_NOT_PRESENT:
077: result += "Called name not present";
078: break;
079: case NO_RESOURCES:
080: result += "Called name present, but insufficient resources";
081: break;
082: case UNSPECIFIED:
083: result += "Unspecified error";
084: break;
085: default:
086: result += "Unknown error code: " + errorCode;
087: }
088: break;
089: default:
090: result += "unknown error class: " + errorClass;
091: }
092: return result;
093: }
094:
095: public NbtException(int errorClass, int errorCode) {
096: super (getErrorString(errorClass, errorCode));
097: this .errorClass = errorClass;
098: this .errorCode = errorCode;
099: }
100:
101: public String toString() {
102: return new String("errorClass=" + errorClass + ",errorCode="
103: + errorCode + ",errorString="
104: + getErrorString(errorClass, errorCode));
105: }
106: }
|