nsbaci 1.0
Loading...
Searching...
No Matches
errorTypes.h
Go to the documentation of this file.
1
12
13#ifndef NSBACI_TYPES_ERRORTYPES_H
14#define NSBACI_TYPES_ERRORTYPES_H
15
16#include <string>
17#include <variant>
18
19#include "fileTypes.h"
20
25namespace nsbaci::types {
26
31enum class ErrSeverity { Warning, Error, Fatal };
32
37enum class ErrType {
38 // File path errors
39 emptyPath, // Path string is empty
40 invalidPath, // Path is malformed or invalid
41 invalidExtension, // File does not have .nsb extension
42 directoryNotFound, // Parent directory doesn't exist
43 fileNotFound, // File doesn't exist
44 notARegularFile, // Path points to directory, symlink, etc.
45
46 // Permission errors
47 permissionDenied, // No read/write access
48
49 // I/O errors
50 openFailed, // Could not open file
51 readFailed, // Error while reading
52 writeFailed, // Error while writing
53
54 // Compilation errors
55 compilationError, // Syntax or semantic error during compilation
56
57 // Generic
58 unknown // Unspecified error
59};
60
61using ErrMessage = std::string;
62
67struct ErrorBase {
68 // this severity serves as an indicator to what icon to use in the error, the
69 // string that appears in the top of the dialog, additional buttons for things
70 // like restart when the error is fatal...
71 ErrSeverity severity;
72 ErrMessage message;
73 // useful to show the reason for things. For example, if when trying to save a
74 // file to a sensible location, if the app doesn't have privileges, the ui can
75 // show a message of type: "/Error/ X could not be saved in Y. Reason:
76 // Permission Denied. Try starting the app in admin mode. [Ok]"
77 ErrType type;
78};
79
85 int line = 0;
86 int column = 0;
87};
88
93struct SaveError {
94 File associatedFile;
95};
96
101struct LoadError {
102 File associatedFile;
103};
104
109struct RuntimeError {};
110
118 std::variant<SaveError, LoadError, CompileError, RuntimeError>;
119
120} // namespace nsbaci::types
121
122#endif // NSBACI_TYPES_ERRORTYPES_H
Represents an error with a message and optional code.
Definition error.h:28
Type definitions for file-related operations.
Type definitions namespace for nsbaci (runtime-specific).
ErrType
Types of errors that can occur in the application.
Definition errorTypes.h:37
ErrSeverity
Severity levels for errors.
Definition errorTypes.h:31
fs::path File
Alias for file system paths.
Definition fileTypes.h:35
std::variant< SaveError, LoadError, CompileError, RuntimeError > ErrorPayload
Variant type for all possible error payloads.
Definition errorTypes.h:117
Error payload for compilation errors.
Definition errorTypes.h:84
Base structure containing common error properties.
Definition errorTypes.h:67
Error payload for file load errors.
Definition errorTypes.h:101
Error payload for runtime errors.
Definition errorTypes.h:109
Error payload for file save errors.
Definition errorTypes.h:93