feat: alias error types through the wl shim
The shim aliased every type a caller needs except the ones used to describe a transport failure, so classifying an error meant importing the root package alongside it. DisplayError, ProtocolError and the four sentinels are now re-exported, and errors.Is works through the shim.
- commit
- ab733e57ccc0898cae8daf4df69fb4e5121c83d2
- author
- brice · · 2026-09-13 06:51 UTC
- parent
- a3a494e
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email - refs
- tag: v0.2.0
1 file · +14 -0
M wl/wl.go +14 -0
| @@ -29,6 +29,11 @@ type ( | |||
| 29 | 29 | Output = wlturbo.Output | |
| 30 | 30 | Region = wlturbo.Region | |
| 31 | 31 | Compositor = wlturbo.Compositor | |
| 32 | + | ||
| 33 | + | // Transport failures. Without these, a caller that imports this shim has to | |
| 34 | + | // import the root package as well just to classify an error. | |
| 35 | + | DisplayError = wlturbo.DisplayError | |
| 36 | + | ProtocolError = wlturbo.ProtocolError | |
| 32 | 37 | ) | |
| 33 | 38 | ||
| 34 | 39 | // Function aliases | |
| @@ -44,6 +49,15 @@ var ( | |||
| 44 | 49 | UnmapMemory = wlturbo.UnmapMemory | |
| 45 | 50 | ) | |
| 46 | 51 | ||
| 52 | + | // Sentinels for the transport's error classes, so errors.Is works through the | |
| 53 | + | // shim as it does through the root package. | |
| 54 | + | var ( | |
| 55 | + | ErrMalformedFrame = wlturbo.ErrMalformedFrame | |
| 56 | + | ErrUnknownObject = wlturbo.ErrUnknownObject | |
| 57 | + | ErrUnknownOpcode = wlturbo.ErrUnknownOpcode | |
| 58 | + | ErrDisplayError = wlturbo.ErrDisplayError | |
| 59 | + | ) | |
| 60 | + | ||
| 47 | 61 | // Seat capability constants | |
| 48 | 62 | const ( | |
| 49 | 63 | SeatCapabilityPointer = wlturbo.SeatCapabilityPointer | |
| @@ -29,6 +29,11 @@ type ( | |||||
| 29 | Output = wlturbo.Output | 29 | Output = wlturbo.Output | ||
| 30 | Region = wlturbo.Region | 30 | Region = wlturbo.Region | ||
| 31 | Compositor = wlturbo.Compositor | 31 | Compositor = wlturbo.Compositor | ||
| 32 | + | ||||
| 33 | + | // Transport failures. Without these, a caller that imports this shim has to | |||
| 34 | + | // import the root package as well just to classify an error. | |||
| 35 | + | DisplayError = wlturbo.DisplayError | |||
| 36 | + | ProtocolError = wlturbo.ProtocolError | |||
| 32 | ) | 37 | ) | ||
| 33 | 38 | ||||
| 34 | // Function aliases | 39 | // Function aliases | ||
| @@ -44,6 +49,15 @@ var ( | |||||
| 44 | UnmapMemory = wlturbo.UnmapMemory | 49 | UnmapMemory = wlturbo.UnmapMemory | ||
| 45 | ) | 50 | ) | ||
| 46 | 51 | ||||
| 52 | + | // Sentinels for the transport's error classes, so errors.Is works through the | |||
| 53 | + | // shim as it does through the root package. | |||
| 54 | + | var ( | |||
| 55 | + | ErrMalformedFrame = wlturbo.ErrMalformedFrame | |||
| 56 | + | ErrUnknownObject = wlturbo.ErrUnknownObject | |||
| 57 | + | ErrUnknownOpcode = wlturbo.ErrUnknownOpcode | |||
| 58 | + | ErrDisplayError = wlturbo.ErrDisplayError | |||
| 59 | + | ) | |||
| 60 | + | ||||
| 47 | // Seat capability constants | 61 | // Seat capability constants | ||
| 48 | const ( | 62 | const ( | ||
| 49 | SeatCapabilityPointer = wlturbo.SeatCapabilityPointer | 63 | SeatCapabilityPointer = wlturbo.SeatCapabilityPointer | ||