1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use std::io;
use std::path::PathBuf;

use bip_util::bt::InfoHash;

error_chain! {
    types {
        BlockError, BlockErrorKind, BlockResultExt, BlockResult;
    }

    foreign_links {
        Io(io::Error);
    }

    errors {
        InfoHashNotFound {
            hash: InfoHash
        } {
            description("Failed To Load/Process Block Because Torrent Is Not Loaded")
            display("Failed To Load/Process Block Because The InfoHash {:?} It Is Not Currently Added", hash)
        }
    }
}

error_chain! {
    types {
        TorrentError, TorrentErrorKind, TorrentResultExt, TorrentResult;
    }

    foreign_links {
        Block(BlockError);
        Io(io::Error);
    }

    errors {
        ExistingFileSizeCheck {
            file_path:     PathBuf,
            expected_size: u64,
            actual_size:   u64
        } {
            description("Failed To Add Torrent Because Size Checker Failed For A File")
            display("Failed To Add Torrent Because Size Checker Failed For {:?} Where File Size Was {} But Should Have Been {}", file_path, actual_size, expected_size)
        }
        ExistingInfoHash {
            hash: InfoHash
        } {
            description("Failed To Add Torrent Because Another Torrent With The Same InfoHash Is Already Added")
            display("Failed To Add Torrent Because Another Torrent With The Same InfoHash {:?} Is Already Added", hash)
        }
        InfoHashNotFound {
            hash: InfoHash
        } {
            description("Failed To Remove Torrent Because It Is Not Currently Added")
            display("Failed To Remove Torrent Because The InfoHash {:?} It Is Not Currently Added", hash)
        }
    }
}