so://phie

verbal

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

blob: 1fba29f99086879c95b7271428da5cf9116aba23 (755 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 Fetch,

12 Parse,

13 Query,

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 {

31 kind,

32 message: message.into(),

33 }

34 }

35}

36

37impl fmt::Display for Error {

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

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

40 }

41}