summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibAudio/LoaderError.h
blob: 12a215af424f8bd895513087a8aa5c4a85b2d7dc (plain)
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
/*
 * Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com>.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/FlyString.h>

namespace Audio {

struct LoaderError {

    enum Category : u32 {
        // The error category is unknown.
        Unknown = 0,
        IO,
        // The read file doesn't follow the file format.
        Format,
        // Equivalent to an ASSERT(), except non-crashing.
        Internal,
        // The loader encountered something in the format that is not yet implemented.
        Unimplemented,
    };
    Category category { Unknown };
    // Binary index: where in the file the error occurred.
    size_t index { 0 };
    FlyString description { String::empty() };

    constexpr LoaderError() = default;
    LoaderError(Category category, size_t index, FlyString description)
        : category(category)
        , index(index)
        , description(move(description))
    {
    }
    LoaderError(FlyString description)
        : description(move(description))
    {
    }
    LoaderError(Category category, FlyString description)
        : category(category)
        , description(move(description))
    {
    }

    LoaderError(LoaderError&) = default;
    LoaderError(LoaderError&&) = default;
};

}