MCPcopy Create free account
hub / github.com/github/copilot-sdk / CanvasError

Class CanvasError

python/copilot/canvas.py:107–139  ·  view source on GitHub ↗

Structured error returned from canvas handlers. .. note:: **Experimental.** This type is part of an experimental wire-protocol surface and may change or be removed in future SDK or CLI releases.

Source from the content-addressed store, hash-verified

105
106
107class CanvasError(Exception):
108 """Structured error returned from canvas handlers.
109
110 .. note::
111
112 **Experimental.** This type is part of an experimental wire-protocol
113 surface and may change or be removed in future SDK or CLI releases.
114 """
115
116 def __init__(self, code: str, message: str) -> None:
117 self.code = code
118 self.message = message
119 super().__init__(f"{code}: {message}")
120
121 def to_envelope(self) -> dict[str, str]:
122 return {"code": self.code, "message": self.message}
123
124 @classmethod
125 def no_handler(cls) -> CanvasError:
126 """Default error returned when a custom action has no handler."""
127 return cls(
128 "canvas_action_no_handler",
129 "No handler implemented for this canvas action",
130 )
131
132 @classmethod
133 def handler_unset(cls) -> CanvasError:
134 """Error returned when a canvas RPC arrives but no handler is installed."""
135 return cls(
136 "canvas_handler_unset",
137 "No CanvasHandler installed on this session; "
138 "install one via SessionConfig.canvas_handler before creating the session.",
139 )
140
141
142class CanvasHandler(ABC):

Callers 2

on_openMethod · 0.90

Calls

no outgoing calls

Tested by 2

on_openMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…