-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigFileException.java
More file actions
77 lines (69 loc) · 2.22 KB
/
ConfigFileException.java
File metadata and controls
77 lines (69 loc) · 2.22 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
72
73
74
75
76
77
package dev.spexx.configurationAPI.api.exceptions;
import org.jetbrains.annotations.NotNull;
import java.io.File;
/**
* Exception related to configuration file operations.
*
* <p>This exception is used when an error occurs while interacting with a file,
* such as missing files, invalid paths, or general I/O-related issues.</p>
*
* <p>It may optionally carry a reference to the file that caused the failure.</p>
*
* @since 1.3.0
*/
public class ConfigFileException extends ConfigException {
/**
* The file associated with the exception, if available.
*
* @since 1.3.0
*/
private final File file;
/**
* Constructs a new {@link ConfigFileException} with a detail message.
*
* @param message the detail message describing the error
* @since 1.3.0
*/
public ConfigFileException(@NotNull String message) {
super(message);
this.file = null;
}
/**
* Constructs a new {@link ConfigFileException} for a specific file.
*
* <p>The file path is appended to the message for easier debugging.</p>
*
* @param file the file related to the error
* @param message the detail message describing the error
* @since 1.3.0
*/
public ConfigFileException(@NotNull File file, @NotNull String message) {
super(message + ": " + file.getAbsolutePath());
this.file = file;
}
/**
* Constructs a new {@link ConfigFileException} for a specific file with a cause.
*
* <p>The file path is appended to the message for easier debugging.</p>
*
* @param file the file related to the error
* @param message the detail message describing the error
* @param cause the underlying cause of the exception
* @since 1.3.0
*/
public ConfigFileException(@NotNull File file,
@NotNull String message,
@NotNull Throwable cause) {
super(message + ": " + file.getAbsolutePath(), cause);
this.file = file;
}
/**
* Returns the file associated with this exception.
*
* @return the file, or {@code null} if not specified
* @since 1.3.0
*/
public File getFile() {
return file;
}
}