2026-07-25 12:39:32 +02:00
|
|
|
/// An error reported by the Playdate OS.
|
|
|
|
|
public struct PlaydateError: Swift.Error, Sendable {
|
2026-07-25 12:55:53 +02:00
|
|
|
/// The message reported by the OS, or a description of the failure.
|
2026-07-25 12:39:32 +02:00
|
|
|
public let message: String
|
|
|
|
|
|
2026-07-25 12:55:53 +02:00
|
|
|
/// Creates an error with the given message.
|
2026-07-25 12:39:32 +02:00
|
|
|
init(message: String) {
|
|
|
|
|
self.message = message
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-25 12:55:53 +02:00
|
|
|
/// Creates an error by copying an OS-provided C string; a nil pointer
|
|
|
|
|
/// produces "unknown error".
|
2026-07-25 12:39:32 +02:00
|
|
|
init(cString: UnsafePointer<CChar>?) {
|
|
|
|
|
self.init(message: String(playdateCString: cString) ?? "unknown error")
|
|
|
|
|
}
|
|
|
|
|
}
|