DIRECTORY IO, Rope, Xl, XlPrivateErrorHandling, XlPrivate, XlTQPrivate; XlSimpleErrorHandlingImpl: CEDAR PROGRAM IMPORTS IO, Rope, Xl, XlPrivate, XlPrivateErrorHandling, XlTQPrivate ~ BEGIN Explain: PROC [errorEvent: Xl.ErrorNotifyEvent] = { Ap0: PROC [r: Rope.ROPE] = { ev.explanation ¬ Rope.Cat[ev.explanation, r, " "]; }; Ap: PROC [format: Rope.ROPE, v1: IO.Value ¬ [null[]]] = { Ap0[IO.PutFR1[format, v1]] }; ev: REF Xl.EventRep.errorNotify; IF errorEvent#NIL AND errorEvent.explanation=NIL THEN { TRUSTED { ev ¬ LOOPHOLE[errorEvent] }; --read-write ev.originalCodeByte ¬ ORD[Xl.EventCode[errorNotify]]; WITH ev.replyText SELECT FROM r: XlPrivate.Reply => { IF XlPrivate.Get8[r, 0]#0 THEN Ap0["package is not an error event"] ELSE { XlPrivate.SetPos[r, 1]; ev.errorKind ¬ VAL[XlPrivate.Read8[r]]; ev.seq ¬ XlPrivate.ERead16[r]; ev.badValue ¬ XlPrivate.ERead32[r]; ev.minorOpCode ¬ XlPrivate.ERead16[r]; ev.majorOpCode ¬ VAL[XlPrivate.ERead8[r]]; SELECT ev.errorKind FROM nil => Ap0["nil error"]; request => Ap["bad request: %g", IO.card[ev.majorOpCode]]; value => Ap["bad value: %g", IO.card[ev.badValue]]; window => Ap["bad window id: %g", IO.card[ev.badValue]]; pixmap => Ap["bad pixmap id: %g", IO.card[ev.badValue]]; atom => Ap["bad atom id: %g", IO.card[ev.badValue]]; cursor => Ap["bad cursor id: %g", IO.card[ev.badValue]]; font => Ap["bad font id: %g", IO.card[ev.badValue]]; match => Ap0["match error"]; drawable => Ap["bad drawable id: %g", IO.card[ev.badValue]]; access => Ap0["access error"]; alloc => Ap0["server out of memory"]; colormap => Ap["bad colormap id: %g", IO.card[ev.badValue]]; gContext => Ap["bad gContext id: %g", IO.card[ev.badValue]]; idChoice => Ap["idChoice error: bad id: %g", IO.card[ev.badValue]]; name => Ap0["name error"]; length => Ap0["length error"]; implementation => Ap0["implementation error"]; connectionWedged => Ap0["connection wedged"]; requestFromDeadConnection => Ap0["connection closed"]; VAL[241] => Ap0["reply inconsistent"]; ENDCASE => Ap["unknown error (%g)", IO.card[ORD[ev.errorKind]]]; Ap[" (majorOpCode: %g)", IO.card[ev.majorOpCode]]; IF ev.minorOpCode#0 THEN Ap[" (minorOpCode: %g)", IO.card[ev.minorOpCode]]; }; }; ENDCASE => {Ap0["reply wrong"]}; }; }; lastErrorEvent: Xl.ErrorNotifyEvent; lastError: Rope.ROPE; lastErrorReply: REF; PrintLastErrorEvent: PROC [] RETURNS [Xl.ErrorNotifyEvent] = { RETURN [lastErrorEvent] }; PrintLastError: PROC [] RETURNS [r: Rope.ROPE] = { RETURN [lastError] }; PrintLastErrorReply: PROC [] RETURNS [REF] = { RETURN [lastErrorReply] }; ErrorEventProc: Xl.EventProcType = { connection: Xl.Connection; originalCodeByte: BYTE; IF event#NIL THEN { connection ¬ event.connection; originalCodeByte ¬ event.originalCodeByte }; WITH event SELECT FROM error: Xl.ErrorNotifyEvent => { XlPrivateErrorHandling.Explain[error]; BEGIN ENABLE ABORTED => { XlTQPrivate.RemoveErrorEvents[tq]; GOTO oops }; sequenceNo: Xl.SequenceNo ¬ error.seq; r: Rope.ROPE ¬ IO.PutFLR["[%g, kind:%g, major:%g, minor:%g, bad: %g] ", LIST[ [rope[error.explanation]], [cardinal[ORD[error.errorKind]]], [cardinal[error.majorOpCode]], [cardinal[error.minorOpCode]], [cardinal[error.badValue]] ] ]; lastErrorEvent ¬ error; lastErrorReply ¬ error.replyText; lastError ¬ Rope.Flatten[r]; SIGNAL Xl.XError[error]; EXITS oops => {}; END; }; ENDCASE => ERROR; }; XlPrivateErrorHandling.RegisterErrorReportProc[ErrorEventProc]; XlPrivateErrorHandling.RegisterExplainer[Explain]; END. ΰXlSimpleErrorHandlingImpl.mesa Copyright Σ 1991 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, November 6, 1991 10:11:20 am PST Christian Jacobi, February 2, 1993 11:35 am PST Non essential impl module for Xl. Registers default error handlers making X errors legible. Willie-s, November 25, 1991 4:47 pm PST --Also makes copies of data so it is visible in Cirio... --Proceeding gets to the next queued error, --Aborting flushes the error queue. ΚŸ•NewlineDelimiter –(cedarcode) style˜codešœ™Kšœ Οeœ1™Kšžœ˜K˜K˜—šŸœžœžœ žœ˜2Kšžœ ˜K˜K˜—šŸœžœžœžœ˜.Kšžœ˜K˜—K˜šŸœ˜$Kšœ8™8Kšœ˜Kšœžœ˜šžœžœžœ˜Kšœ˜Kšœ)˜)Kšœ˜—šžœžœž˜šœ ˜ Kšœ&˜&šž˜šžœžœ˜Kšœ#žœ˜,Kšœ˜—Kšœ&˜&šœžœžœ7˜HKšžœ˜ Kšœ žœ˜!Kšœ˜Kšœ˜Kšœ˜Kšœ˜—Kšœ˜Kšœ!˜!Kšœ˜K˜Kšžœ˜Kš Ρbcn   ™,Kšœ‘ ™#K˜Kšžœ ˜Kšžœ˜—K˜—Kšžœžœ˜—Kšœ˜—K˜K˜?Kšœ2˜2Kšžœ˜K˜—…— †