XNSFilingErrorImpl.mesa
Copyright Ó 1990 by Xerox Corporation. All rights reserved.
Bill Jackson (bj), May 30, 1990 2:03 pm PDT
DIRECTORY
AuthenticationP14V2 USING [CallProblem, Problem],
BasicTime USING [GMT, Now, nullGMT],
CrRPC USING [Error, ErrorReason],
FilingAttributesP10V5,
FilingP10V5,
IO USING [card, EndOfStream, Error, PutFR, rope, time],
PFS USING [Error, ErrorDesc],
PFSBackdoor USING [ErrorCode, ProduceError],
RefText USING [TrustTextAsRope],
Rope USING [ROPE],
XNSFilingOps USING [ServerData],
XNSStream USING [ConnectionClosed, Timeout];
XNSFilingErrorImpl: CEDAR MONITOR
IMPORTS CrRPC, IO, FilingP10V5, PFS, PFSBackdoor, RefText, XNSStream
EXPORTS XNSFilingOps ~ {
ROPE: TYPE ~ Rope.ROPE;
Hack
AtomForErrorCode: PROC [code: InternalErrorCode] RETURNS [atom: ATOM] ~ {
atom ← SELECT code FROM
badCredentials => $badCredentials,
illegalAttributeType => $illegalAttributeType,
illegalAttributeValue => $illegalAttributeValue,
illegalControlType => $illegalControlType,
illegalControlValue => $illegalControlValue,
illegalScope => $illegalScope,
illegalScopeValue => $illegalScopeValue,
illegalSession => $illegalSession,
fileBusy => $fileBusy,
fileHandleError => $fileHandleError,
insertionError => $insertionError,
rangeError => $rangeError,
crRPCError => $crRPCError,
unexpectedClose => $unexpectedClose,
connectionTimedOut => $connectionTimedOut,
connectionTrouble => $connectionTrouble,
serviceProblem => $serviceProblem,
transferError => $transferError,
undefinedError => $undefinedError,
ENDCASE => ERROR;
};
InternalErrorCode: TYPE ~ {
--user:-- badCredentials,
--client:-- illegalAttributeType, illegalAttributeValue, illegalControlType, illegalControlValue, illegalScope, illegalScopeValue,
--client:-- illegalSession, fileBusy, fileHandleError, insertionError, rangeError,
--environ:-- crRPCError, unexpectedClose, connectionTimedOut, connectionTrouble, serviceProblem, transferError,
--bug:-- undefinedError
};
Bug: PROC [code: InternalErrorCode[undefinedError..undefinedError], msg: ROPE] ~ {
atom: ATOM ~ AtomForErrorCode[code];
error: PFS.ErrorDesc ~ [$bug, atom, msg];
ERROR PFS.Error[error];
};
ClientError: PROC [code: InternalErrorCode[illegalAttributeType..rangeError], msg: ROPE] ~ {
atom: ATOM ~ AtomForErrorCode[code];
error: PFS.ErrorDesc ~ [$client, atom, msg];
ERROR PFS.Error[error];
};
EnvironError: PROC [code: InternalErrorCode[crRPCError..transferError], msg: ROPE] ~ {
atom: ATOM ~ AtomForErrorCode[code];
error: PFS.ErrorDesc ~ [$environment, atom, msg];
ERROR PFS.Error[error];
};
UserError: PROC [code: InternalErrorCode[badCredentials..badCredentials], msg: ROPE] ~ {
atom: ATOM ~ AtomForErrorCode[code];
error: PFS.ErrorDesc ~ [$user, atom, msg];
ERROR PFS.Error[error];
};
BackdoorError: PROC [code: PFSBackdoor.ErrorCode, msg: ROPE] ~ INLINE {
PFSBackdoor.ProduceError[code, msg];
};
UnknownError: PROC [pathname: ROPE, time: BasicTime.GMT] ~ {
msg: ROPE ~ IO.PutFR["%g of %g", IO.rope[pathname], IO.time[time] ];
BackdoorError[$unknownFile, msg];
};
Error Catching and Reporting
StartCall: ENTRY PROC [mnt: XNSFilingOps.ServerData] ~ {
ENABLE UNWIND => { NULL };
mnt.admin.callsOut ← mnt.admin.callsOut.SUCC;
mnt.admin.active ← TRUE;
};
EndCall: ENTRY PROC [mnt: XNSFilingOps.ServerData] ~ {
ENABLE UNWIND => { NULL };
mnt.admin.callsOut ← mnt.admin.callsOut.PRED;
mnt.admin.active ← (mnt.admin.callsOut > 0);
mnt.admin.lastOp ← BasicTime.Now[];
};
CallProtected: PUBLIC PROC [mnt: XNSFilingOps.ServerData, proc: PROC,
pathname: ROPE, time: BasicTime.GMT] ~ {
ENABLE UNWIND => { EndCall[mnt] };
StartCall[mnt];
GuardOpInner[proc, pathname, time];
EndCall[mnt];
};
GuardOp: PUBLIC PROC [proc: PROC] ~ {
GuardOpInner[proc];
};
GuardOpInner: PUBLIC PROC [proc: PROC,
pathname: ROPENIL, time: BasicTime.GMT ← BasicTime.nullGMT] ~ {
ENABLE {
UNWIND => { NULL };
XNSStream.ConnectionClosed => {
xx: ROPE ~ IO.PutFR[RopeForText["Server for %g closed the connection."],
IO.rope[pathname] ];
EnvironError[$connectionTimedOut, xx];
};
CrRPC.Error => {
text2: ROPE ~ RopeForText[errorReasonText[errorReason]];
xx: ROPE ~ IO.PutFR[RopeForText["CrRPC.Error[%g]: %g"],
IO.rope[text2], IO.rope[text] ];
EnvironError[$crRPCError, xx];
};
IO.EndOfStream => {
xx: ROPE ~ IO.PutFR[RopeForText["Server for %g closed the connection."],
IO.rope[pathname] ];
EnvironError[$unexpectedClose, xx];
};
IO.Error => {
xx: ROPE ~ IO.PutFR[RopeForText["File: %g unexpected IO.Error."],
IO.rope[pathname] ];
BackdoorError[$ioError, xx];
};
FilingP10V5.AccessError => {
text: ROPE ~ RopeForText[accessProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AccessError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
SELECT problem FROM
accessRightsInsufficient,
accessRightsIndeterminate => BackdoorError[$accessDenied, xx];
fileChanged,
fileDamaged => BackdoorError[$inconsistent, xx];
fileInUse, fileOpen => ClientError[$fileBusy, xx];
fileNotFound => UnknownError[pathname, time];
ENDCASE => ERROR;
};
FilingP10V5.AttributeTypeError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AttributeTypeError[%g]: %g"],
IO.rope[text], IO.card[type] ];
ClientError[$illegalAttributeType, xx];
};
FilingP10V5.AttributeValueError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AttributeValueError[%g]: %g"],
IO.rope[text], IO.card[type] ];
ClientError[$illegalAttributeValue, xx];
};
FilingP10V5.AuthenticationError => {
text: ROPE ~ RopeForText[problemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AuthenticationError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
UserError[$badCredentials, xx];
};
FilingP10V5.ConnectionError => {
text: ROPE ~ RopeForText[connectionProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ConnectionError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
EnvironError[$connectionTrouble, xx];
};
FilingP10V5.ControlTypeError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
text2: ROPE ~ RopeForText[controlTypeText[type]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ControlTypeError[%g]: %g"],
IO.rope[text], IO.rope[text2] ];
ClientError[$illegalControlType, xx];
};
FilingP10V5.ControlValueError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
text2: ROPE ~ RopeForText[controlTypeText[type]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ControlValueError[%g]: %g"],
IO.rope[text], IO.rope[text2] ];
ClientError[$illegalControlValue, xx];
};
FilingP10V5.HandleError => {
text: ROPE ~ RopeForText[handleProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.HandleError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
ClientError[$fileHandleError, xx];
};
FilingP10V5.InsertionError => {
text: ROPE ~ RopeForText[insertionProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.InsertionError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
ClientError[$insertionError, xx];
};
FilingP10V5.RangeError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.RangeError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
ClientError[$rangeError, xx];
};
FilingP10V5.ScopeTypeError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
text2: ROPE ~ RopeForText[scopeTypeText[type]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ScopeTypeError[%g]: %g"],
IO.rope[text], IO.rope[text2] ];
ClientError[$illegalScope, xx];
};
FilingP10V5.ScopeValueError => {
text: ROPE ~ RopeForText[argumentProblemText[problem]];
text2: ROPE ~ RopeForText[scopeTypeText[type]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ScopeTypeError[%g]: %g"],
IO.rope[text], IO.rope[text2] ];
ClientError[$illegalScopeValue, xx];
};
FilingP10V5.ServiceError => {
text: ROPE ~ RopeForText[serviceProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ServiceError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
EnvironError[$serviceProblem, xx];
};
FilingP10V5.SessionError => {
text: ROPE ~ RopeForText[sessionProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.SessionError[%g]: %g"],
IO.rope[text] ];
ClientError[$illegalSession, xx];
};
FilingP10V5.SpaceError => {
text: ROPE ~ RopeForText[spaceProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.SpaceError[%g]: %g"],
IO.rope[text] ];
BackdoorError[(SELECT problem FROM
allocationExceeded => $quotaExceeded,
attributeAreaFull => $outOfPropertySpace,
mediumFull => $volumeFull,
ENDCASE => ERROR), xx];
};
FilingP10V5.TransferError => {
text: ROPE ~ RopeForText[transferProblemText[problem]];
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.TransferError[%g]: %g"],
IO.rope[text], IO.rope[pathname] ];
EnvironError[$transferError, xx];
};
FilingP10V5.UndefinedError => {
xx: ROPE ~ IO.PutFR[RopeForText["Filing5.UndefinedError[%g]: %g"],
IO.card[problem], IO.rope[pathname] ];
Bug[$undefinedError, xx];
};
};
IF ( proc = NIL ) THEN ERROR;
proc[ ! XNSStream.Timeout => RESUME]; -- since the timeout is retryable
};
Text Arrays
RopeForText: PROC [text: STRING] RETURNS [rope: ROPE] ~ {
avoid: XR𡤊ssignRefInit((word) xx, (word) XR←GetRefLiteral((* xx ), (word) &string));
ref: REF READONLY TEXT;
TRUSTED { ref ← LOOPHOLE[text] };
rope ← RefText.TrustTextAsRope[ref];
};
REQUIREDTEXT: TYPE ~ <<READONLY>> STRING ← ; -- no default value!
AuthenticationP14V2
callProblemText: PUBLIC ARRAY AuthenticationP14V2.CallProblem OF REQUIREDTEXT ← [
tooBusy: "tooBusy",
accessRightsInsufficient: "accessRightsInsufficient",
keysUnavailable: "keysUnavailable",
strongKeyDoesNotExist: "strongKeyDoesNotExist",
simpleKeyDoesNotExist: "simpleKeyDoesNotExist",
strongKeyAlreadyRegistered: "strongKeyAlreadyRegistered",
simpleKeyAlreadyRegistered: "simpleKeyAlreadyRegistered",
domainForNewKeyUnavailable: "domainForNewKeyUnavailable",
domainForNewKeyUnknown: "domainForNewKeyUnknown",
badKey: "badKey",
badName: "badName",
databaseFull: "databaseFull",
other: "other"
];
problemText: PUBLIC ARRAY AuthenticationP14V2.Problem OF REQUIREDTEXT ← [
credentialsInvalid: "credentialsInvalid",
verifierInvalid: "verifierInvalid",
verifierExpired: "verifierExpired",
verifierReused: "verifierReused",
credentialsExpired: "credentialsExpired",
inappropriateCredentials: "inappropriateCredentials"
];
CrRPC
errorReasonText: PUBLIC ARRAY CrRPC.ErrorReason OF REQUIREDTEXT ← [
unknown: "unknown",
unknownClass: "unknownClass",
courierVersionMismatch: "courierVersionMismatch",
rejectedNoSuchProgram: "rejectedNoSuchProgram",
rejectedNoSuchVersion: "rejectedNoSuchVersion",
rejectedNoSuchProcedure: "rejectedNoSuchProcedure",
rejectedInvalidArgument: "rejectedInvalidArgument",
rejectedUnspecified: "rejectedUnspecified",
remoteError: "remoteError",
cantConnectToRemote: "cantConnectToRemote",
argsError: "argsError",
resultsError: "resultsError",
bulkDataError: "bulkDataError",
protocolError: "protocolError",
remoteClose: "remoteClose",
communicationFailure: "communicationFailure",
notImplemented: "notImplemented",
unknownOperation: "unknownOperation",
notServerHandle: "notServerHandle",
notClientHandle: "notClientHandle",
addressInappropriateForClass: "addressInappropriateForClass",
other: "other"
];
FilingP10V5
accessProblemText: PUBLIC ARRAY FilingP10V5.AccessProblem OF REQUIREDTEXT ← [
accessRightsInsufficient: "accessRightsInsufficient",
accessRightsIndeterminate: "accessRightsIndeterminate",
fileChanged: "fileChanged",
fileDamaged: "fileDamaged",
fileInUse: "fileInUse",
fileNotFound: "fileNotFound",
fileOpen: "fileOpen"
];
argumentProblemText: PUBLIC ARRAY FilingP10V5.ArgumentProblem OF REQUIREDTEXT ← [
illegal: "illegal",
disallowed: "disallowed",
unreasonable: "unreasonable",
unimplemented: "unimplemented",
duplicated: "duplicated",
missing: "missing"
];
ConnectionProblemSubRange: TYPE ~ FilingP10V5. ConnectionProblem[noRoute..returnTimedOut];
connectionProblemText: PUBLIC ARRAY ConnectionProblemSubRange OF REQUIREDTEXT ← [
noRoute: "noRoute",
noResponse: "noResponse",
transmissionHardware: "transmissionHardware",
transportTimeout: "transportTimeout",
tooManyLocalConnections: "tooManyLocalConnections",
tooManyRemoteConnections: "tooManyRemoteConnections",
missingCourier: "missingCourier",
missingProgram: "missingProgram",
missingProcedure: "missingProcedure",
protocolMismatch: "protocolMismatch",
parameterInconsistency: "parameterInconsistency",
invalidMessage: "invalidMessage",
returnTimedOut: "returnTimedOut"
];
controlTypeText: PUBLIC ARRAY FilingP10V5.ControlType OF REQUIREDTEXT ← [
lock: "lock",
timeout: "timeout",
access: "access"
];
directionText: PUBLIC ARRAY FilingP10V5.Direction OF REQUIREDTEXT ← [
forward: "forward",
backward: "backward"
];
filterTypeText: PUBLIC ARRAY FilingP10V5.FilterType OF REQUIREDTEXT ← [
less: "less",
lessOrEqual: "lessOrEqual",
equal: "equal",
notEqual: "notEqual",
greaterOrEqual: "greaterOrEqual",
greater: "greater",
and: "and",
or: "or",
not: "not",
none: "none",
all: "all",
matches: "matches"
];
handleProblemText: PUBLIC ARRAY FilingP10V5.HandleProblem OF REQUIREDTEXT ← [
invalid: "invalid",
nullDisallowed: "nullDisallowed",
directoryRequired: "directoryRequired"
];
insertionProblemText: PUBLIC ARRAY FilingP10V5.InsertionProblem OF REQUIREDTEXT ← [
positionUnavailable: "positionUnavailable",
fileNotUnique: "fileNotUnique",
loopInHierarchy: "loopInHierarchy"
];
lockText: PUBLIC ARRAY FilingP10V5.Lock OF REQUIREDTEXT ← [
lockNone: "lockNone",
share: "share",
exclusive: "exclusive"
];
scopeTypeText: PUBLIC ARRAY FilingP10V5.ScopeType OF REQUIREDTEXT ← [
count: "count",
direction: "direction",
filter: "filter",
depth: "depth"
];
serviceProblemText: PUBLIC ARRAY FilingP10V5.ServiceProblem OF REQUIREDTEXT ← [
cannotAuthenticate: "cannotAuthenticate",
serviceFull: "serviceFull",
serviceUnavailable: "serviceUnavailable",
sessionInUse: "sessionInUse",
serviceUnknown: "serviceUnknown"
];
sessionProblemText: PUBLIC ARRAY FilingP10V5.SessionProblem OF REQUIREDTEXT ← [
tokenInvalid: "tokenInvalid",
serviceAlreadySet: "serviceAlreadySet"
];
spaceProblemText: PUBLIC ARRAY FilingP10V5.SpaceProblem OF REQUIREDTEXT ← [
allocationExceeded: "allocationExceeded",
attributeAreaFull: "attributeAreaFull",
mediumFull: "mediumFull"
];
strengthText: PUBLIC ARRAY FilingP10V5.Strength OF REQUIREDTEXT ← [
none: "none",
simple: "simple",
strong: "strong"
];
transferProblemText: PUBLIC ARRAY FilingP10V5.TransferProblem OF REQUIREDTEXT ← [
aborted: "aborted",
checksumIncorrect: "checksumIncorrect",
formatIncorrect: "formatIncorrect",
noRendevous: "noRendevous",
wrongDirection: "wrongDirection"
];
}.