Repository navigation
Expand file tree
/
Copy patherrors.go
More file actions
71 lines (63 loc) · 2.72 KB
/
Copy patherrors.go
File metadata and controls
71 lines (63 loc) · 2.72 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* fathomry
* Copyright (C) 2026 Frost Leo
* SPDX-License-Identifier: GPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package mysql
import (
"errors"
"fmt"
"io"
"log/slog"
"github.com/frost-leo/fathomry/internal/fault"
)
const ProviderID = "database.mysql.v1"
const (
ErrInput fault.Kind = "fathomry." + ProviderID + ".input"
ErrUnsupported fault.Kind = "fathomry." + ProviderID + ".unsupported"
ErrConnect fault.Kind = "fathomry." + ProviderID + ".connect"
ErrQuery fault.Kind = "fathomry." + ProviderID + ".query"
ErrLimit fault.Kind = "fathomry." + ProviderID + ".limit"
ErrProtocol fault.Kind = "fathomry." + ProviderID + ".protocol"
ErrState fault.Kind = "fathomry." + ProviderID + ".state"
ErrCleanup fault.Kind = "fathomry." + ProviderID + ".cleanup"
)
func failure(kind fault.Kind, operation string, causes ...error) error {
return kind.New(fault.Context{Provider: ProviderID, Operation: operation}, causes...)
}
func joined(kind fault.Kind, operation string, causes ...error) error {
for _, cause := range causes {
if cause != nil {
return failure(kind, operation, causes...)
}
}
return nil
}
type private struct{}
func (private) Format(state fmt.State, _ rune) { _, _ = io.WriteString(state, "mysql[restricted]") }
func (private) MarshalJSON() ([]byte, error) {
return nil, errors.New("mysql: runtime serialization unsupported")
}
func (*private) UnmarshalJSON([]byte) error {
return errors.New("mysql: runtime reconstruction unsupported")
}
func (*OptionsV1) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }
func (*Source) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }
func (*Database) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }
func (*Transaction) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }
func (*Result) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }
func (*Row) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }
func (*Statement) LogValue() slog.Value { return slog.StringValue("mysql[restricted]") }