so://phie

verbal

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

blob: 5f1bc536e251b8611c3963f502164f9cd40a0921 (744 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}

14

15impl fmt::Display for ErrorKind {

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

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

18 }

19}

20

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

22pub struct Error {

23 kind: ErrorKind,

24 message: String,

25}

26

27impl Error {

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

29 Self {

30 kind,

31 message: message.into(),

32 }

33 }

34}

35

36impl fmt::Display for Error {

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

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

39 }

40}