pub enum JsonbError {
Show 16 variants
InvalidToken,
InvalidEscape,
UnescapedControlCharacter,
UnicodeEscapeFormat,
HighSurrogateRepeated,
LowSurrogateExpected,
CodePointZero,
ExpectedValue,
ExpectedString,
ExpectedStringOrObjectEnd,
ExpectedColon,
ExpectedCommaOrObjectEnd,
ExpectedCommaOrArrayEnd,
ExpectedEnd,
UnexpectedEnd,
Numeric(NumericError),
}Expand description
Why jsonb_in refuses a text, one variant per detail PostgreSQL gives, each printed as
PostgreSQL’s message and detail without the token it quotes.
use sql_values::postgres::{JsonbError, NumericError, PgJsonb};
assert_eq!(PgJsonb::parse(r#"{"a":1,}"#), Err(JsonbError::ExpectedString));
assert_eq!(PgJsonb::parse("01"), Err(JsonbError::InvalidToken));
assert_eq!(PgJsonb::parse(r#""\ud83d""#), Err(JsonbError::LowSurrogateExpected));
assert_eq!(
PgJsonb::parse("1e1000000"),
Err(JsonbError::Numeric(NumericError::FormatOverflow)),
);
assert_eq!(
PgJsonb::parse(r#""\u0000""#).unwrap_err().to_string(),
r"unsupported Unicode escape sequence: \u0000 cannot be converted to text",
);Variants§
InvalidToken
A word other than true, false and null, a malformed number, a character that
starts no token, or a string the input ends inside.
InvalidEscape
A backslash followed by a character that escapes nothing.
UnescapedControlCharacter
A control character below 0x20 written in a string without an escape.
UnicodeEscapeFormat
A \u not followed by four hexadecimal digits.
HighSurrogateRepeated
A high surrogate escape directly after another.
LowSurrogateExpected
A low surrogate escape without a high surrogate before it, or a high surrogate escape followed by anything but a low surrogate escape.
CodePointZero
The escape \u0000, which text cannot hold.
ExpectedValue
A token where a value belongs.
ExpectedString
A token other than a key after a comma in an object.
ExpectedStringOrObjectEnd
A token other than a key or } after {.
ExpectedColon
A token other than : after a key.
ExpectedCommaOrObjectEnd
A token other than , or } after a value in an object.
ExpectedCommaOrArrayEnd
A token other than , or ] after an element in an array.
ExpectedEnd
A token after the whole value.
UnexpectedEnd
Input that ends before its value does.
Numeric(NumericError)
A number numeric_in refuses, one beyond the weight or scale PostgreSQL stores.
Trait Implementations§
Source§impl Clone for JsonbError
impl Clone for JsonbError
impl Copy for JsonbError
Source§impl Debug for JsonbError
impl Debug for JsonbError
Source§impl Display for JsonbError
impl Display for JsonbError
impl Eq for JsonbError
Source§impl Error for JsonbError
impl Error for JsonbError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()