<> <> <<>> <> <> DIRECTORY IPErrors USING [AppearanceErrorType, AppearanceWarningType, Error, MasterErrorType, MasterWarningType], Rope USING [Concat, ROPE]; IPErrorsImpl: CEDAR PROGRAM IMPORTS Rope EXPORTS IPErrors = BEGIN OPEN IPErrors; MasterError: PUBLIC ERROR[type: MasterErrorType] = CODE; MasterWarning: PUBLIC SIGNAL[type: MasterWarningType] = CODE; AppearanceError: PUBLIC SIGNAL[type: AppearanceErrorType] = CODE; AppearanceWarning: PUBLIC SIGNAL[type: AppearanceWarningType] = CODE; Bug: PUBLIC ERROR = CODE; Name: TYPE = Rope.ROPE _; -- can't default MENames: TYPE = ARRAY MasterErrorType OF Name; MWNames: TYPE = ARRAY MasterWarningType OF Name; AENames: TYPE = ARRAY AppearanceErrorType OF Name; AWNames: TYPE = ARRAY AppearanceWarningType OF Name; masterErrors: REF MENames = NEW[MENames _ [ BoundsFault: "bounds fault", InvalidArgs: "invalid arguments", LimitExceeded: "limit exceeded", MalformedSkeleton: "malformed skeleton", MarkMismatch: "mark mismatch", MissingBody: "missing body", NarrowFailed: "narrow failed", StackOverflow: "stack overflow", StackUnderflow: "stack underflow", UndefinedProperty: "undefined property", Unimplemented: "unimplemented", WrongType: "wrong type" ]]; masterWarnings: REF MWNames = NEW[MWNames _ [ InvalidArgs: "invalid arguments", NullValue: "null value", Unimplemented: "unimplemented" ]]; appearanceErrors: REF AENames = NEW[AENames _ [ Unimplemented: "unimplemented" ]]; appearanceWarnings: REF AWNames = NEW[AWNames _ [ Unimplemented: "unimplemented" ]]; RopeFromError: PUBLIC PROC[error: Error] RETURNS[Rope.ROPE] = { WITH error SELECT FROM e: Error[Me] => RETURN[Rope.Concat["Master error: ", masterErrors[e.type]]]; e: Error[Mw] => RETURN[Rope.Concat["Master warning: ", masterWarnings[e.type]]]; e: Error[Ae] => RETURN[Rope.Concat["Appearance error: ", appearanceErrors[e.type]]]; e: Error[Aw] => RETURN[Rope.Concat["Appearance warning: ", appearanceWarnings[e.type]]]; ENDCASE => ERROR; }; END.