pub struct ErrorPanel { /* private fields */ }Expand description
A panel specifically designed for error display.
Provides rich formatting for error messages including SQL context, position markers, hints, and SQLSTATE codes.
Implementations§
Source§impl ErrorPanel
impl ErrorPanel
Sourcepub fn new(title: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(title: impl Into<String>, message: impl Into<String>) -> Self
Create a new error panel with title and message.
§Example
use sqlmodel_console::renderables::ErrorPanel;
let panel = ErrorPanel::new("Connection Error", "Failed to connect to database");Sourcepub fn severity(self, severity: ErrorSeverity) -> Self
pub fn severity(self, severity: ErrorSeverity) -> Self
Set error severity.
Sourcepub fn with_position(self, position: usize) -> Self
pub fn with_position(self, position: usize) -> Self
Add error position in SQL (1-indexed character position).
Sourcepub fn with_sqlstate(self, code: impl Into<String>) -> Self
pub fn with_sqlstate(self, code: impl Into<String>) -> Self
Add SQLSTATE code.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Add detail message.
Sourcepub fn add_context(self, line: impl Into<String>) -> Self
pub fn add_context(self, line: impl Into<String>) -> Self
Add context line.
Sourcepub fn get_severity(&self) -> ErrorSeverity
pub fn get_severity(&self) -> ErrorSeverity
Get the severity level.
Sourcepub fn get_message(&self) -> &str
pub fn get_message(&self) -> &str
Get the message.
Sourcepub fn get_position(&self) -> Option<usize>
pub fn get_position(&self) -> Option<usize>
Get the SQL position if set.
Sourcepub fn get_sqlstate(&self) -> Option<&str>
pub fn get_sqlstate(&self) -> Option<&str>
Get the SQLSTATE code if set.
Sourcepub fn get_detail(&self) -> Option<&str>
pub fn get_detail(&self) -> Option<&str>
Get the detail message if set.
Sourcepub fn get_context(&self) -> &[String]
pub fn get_context(&self) -> &[String]
Get the context lines.
Sourcepub fn render_plain(&self) -> String
pub fn render_plain(&self) -> String
Render as plain text.
Returns a structured plain text representation suitable for non-TTY environments or agent consumption.
Sourcepub fn render_styled(&self) -> String
pub fn render_styled(&self) -> String
Render as styled text with ANSI colors and box drawing.
Returns a rich panel representation with colored borders and formatted content.
Trait Implementations§
Source§impl Clone for ErrorPanel
impl Clone for ErrorPanel
Source§fn clone(&self) -> ErrorPanel
fn clone(&self) -> ErrorPanel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ErrorPanel
impl Debug for ErrorPanel
Auto Trait Implementations§
impl Freeze for ErrorPanel
impl RefUnwindSafe for ErrorPanel
impl Send for ErrorPanel
impl Sync for ErrorPanel
impl Unpin for ErrorPanel
impl UnwindSafe for ErrorPanel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more