MCPcopy Create free account
hub / github.com/PRQL/prql / fmt

Method fmt

prqlc/prqlc-parser/src/error.rs:106–138  ·  view source on GitHub ↗
(&self, f: &mut std::fmt::Formatter<'_>)

Source from the content-addressed store, hash-verified

104
105impl std::fmt::Display for Reason {
106 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
107 match self {
108 Reason::Simple(text) => f.write_str(text),
109 Reason::Expected {
110 who,
111 expected,
112 found,
113 } => {
114 if let Some(who) = who {
115 write!(f, "{who} ")?;
116 }
117 write!(f, "expected {expected}, but found {found}")
118 }
119 Reason::Unexpected { found } => write!(f, "unexpected {found}"),
120 Reason::NotFound { name, namespace } => write!(f, "{namespace} `{name}` not found"),
121 Reason::Bug { issue, details } => {
122 write!(f, "internal compiler error")?;
123 if let Some(details) = details {
124 write!(f, "; {details}")?;
125 }
126 if let Some(issue_no) = issue {
127 write!(
128 f,
129 "; tracked at https://github.com/PRQL/prql/issues/{issue_no}"
130 )?;
131 }
132 Ok(())
133 }
134 Reason::Internal { message } => {
135 write!(f, "internal error: {message}")
136 }
137 }
138 }
139}
140
141impl From<Error> for Errors {

Callers

nothing calls this directly

Calls 1

write_strMethod · 0.80

Tested by

no test coverage detected