Repository navigation
Expand file tree
/
Copy pathwrite_errors.go
More file actions
59 lines (50 loc) · 2.94 KB
/
Copy pathwrite_errors.go
File metadata and controls
59 lines (50 loc) · 2.94 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
package audiometa
import "github.com/simonhull/audiometa/internal/types"
// Errors returned by the write API ([File.WriteTo], [Write], the artwork
// edit methods and the ReplayGain setters). They are always returned wrapped
// with detail, so test for them with [errors.Is], never with ==.
var (
// ErrUnsupportedWrite is returned (wrapped) by [File.WriteTo] and [Write]
// when the file's format has no writer, when an edit cannot be represented
// in the format (a typed field the format has no tag for, a picture type
// the format cannot store), or when f.Chapters was changed: chapters are
// preserved but cannot be edited.
ErrUnsupportedWrite = types.ErrUnsupportedWrite
// ErrDRMProtected is returned (wrapped) by [File.WriteTo] and [Write] for
// encrypted or DRM-protected files. Such files are never rewritten.
ErrDRMProtected = types.ErrDRMProtected
// ErrTagTooLarge is returned (wrapped) by [File.WriteTo] and [Write] when
// the serialized metadata would exceed a limit of the format, such as the
// 16 MiB limit of a FLAC metadata block or the 256 MiB limit of an ID3v2
// tag.
ErrTagTooLarge = types.ErrTagTooLarge
// ErrConflictingEdits is returned (wrapped) by [File.WriteTo] and [Write]
// when the pending edits contradict each other: a typed field and the raw
// key it is read from were both changed to different values (for example
// Tags.Set("TIT2", "A") and Tags.Title = "B" on an MP3), Artist was set to
// something other than the first of Artists, or Year disagrees with the
// year of Date.
ErrConflictingEdits = types.ErrConflictingEdits
// ErrInvalidArtwork is returned (wrapped) by [File.AddArtwork] and
// [File.ReplaceArtwork] when the image is rejected: it has no data, its
// Type is not a valid [ArtworkType], its Description is not valid UTF-8,
// or its MIMEType is empty and cannot be detected from the data.
ErrInvalidArtwork = types.ErrInvalidArtwork
// ErrInvalidReplayGain is returned (wrapped) by [File.SetTrackReplayGain]
// and [File.SetAlbumReplayGain] when a value cannot be stored: a gain or
// peak that is NaN or infinite, a negative peak, or an Opus gain outside
// the range of an R128 tag.
ErrInvalidReplayGain = types.ErrInvalidReplayGain
// ErrConcurrentModification is returned (wrapped) by [Write] when the file
// was replaced or changed on disk (its identity, size, modification time
// or, on Linux and macOS, inode change time) between the moment Write
// opened it and the moment it would have been replaced. The file is
// left as the other writer left it.
ErrConcurrentModification = types.ErrConcurrentModification
// ErrVerifyFailed is returned (wrapped) by [Write] when the new file,
// read back before it replaces the original, cannot be parsed, has
// different audio data or has different chapters. The original file is
// left as it was: its contents and modification time are restored after a
// failed in-place write ([WithInPlace]).
ErrVerifyFailed = types.ErrVerifyFailed
)