so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 1ceab9c941febc3857d8346572a1e5b7b0f44b68 (722 bytes)[doc][blame][raw]

1use std::fmt;

2

3use serde::Serialize;

4

5pub type Result<T> = std::result::Result<T, Error>;

6

7#[derive(Debug, Clone, Serialize)]

8pub enum ErrorKind {

9 Identity,

10 Arguments,

11 Query,

12 Fetch,

13 Parse,

14}

15

16impl fmt::Display for ErrorKind {

17 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

18 write!(f, "{:?}", self)

19 }

20}

21

22#[derive(Debug, Clone, Serialize)]

23pub struct Error {

24 kind: ErrorKind,

25 message: String,

26}

27

28impl Error {

29 pub fn new(kind: ErrorKind, message: &str) -> Self {

30 Self { kind, message: message.into() }

31 }

32}

33

34impl fmt::Display for Error {

35 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

36 write!(f, "[{}] {}", self.kind, self.message)

37 }

38}