iVS3D v2.0.0
Loading...
Searching...
No Matches
NeuralError.h
Go to the documentation of this file.
1#pragma once
2
10#include <ostream>
11#include <string>
12
13namespace NN {
14
29enum class ErrorCode {
30 InvalidArgument,
31 OutOfMemory,
32 RuntimeError
33};
34
35
49public:
50 NeuralError(ErrorCode code, const std::string& message)
51 : m_code(code), m_message(message) {}
52
53 ErrorCode code() const { return m_code; }
54 std::string message() const { return m_message; }
55
56private:
57 ErrorCode m_code;
58 std::string m_message;
59};
60
61// Helper function to convert ErrorCode to string
62inline const char* to_string(ErrorCode code) {
63 switch (code) {
64 case ErrorCode::InvalidArgument: return "InvalidArgument";
65 case ErrorCode::OutOfMemory: return "OutOfMemory";
66 case ErrorCode::RuntimeError: return "RuntimeError";
67 default: return "UnknownError";
68 }
69}
70
71// Overload operator<< for NeuralError
72inline std::ostream& operator<<(std::ostream& os, const NeuralError& err) {
73 os << "[" << to_string(err.code()) << "] " << err.message();
74 return os;
75}
76
77} // namespace NN
Represents an error that occurred in the neural network module and contains the error type and messag...
Definition NeuralError.h:48
ErrorCode
Error codes for the neural network module.
Definition NeuralError.h:29
NN Neural Network Library containing Tensor and NeuralNet classes for inference.
Definition NeuralError.h:13