errors.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 namespace mcap {
6 
10 enum class StatusCode {
11  Success = 0,
12  NotOpen,
16  ReadFailed,
26  OpenFailed,
30 };
31 
35 struct [[nodiscard]] Status {
37  std::string message;
38 
40  : code(StatusCode::Success) {}
41 
43  : code(code) {
44  switch (code) {
46  break;
48  message = "not open";
49  break;
51  message = "invalid schema id";
52  break;
54  message = "invalid channel id";
55  break;
57  message = "file too small";
58  break;
60  message = "read failed";
61  break;
63  message = "magic mismatch";
64  break;
66  message = "invalid file";
67  break;
69  message = "invalid record";
70  break;
72  message = "invalid opcode";
73  break;
75  message = "invalid chunk offset";
76  break;
78  message = "invalid footer";
79  break;
81  message = "decompression failed";
82  break;
84  message = "decompression size mismatch";
85  break;
87  message = "unrecognized compression";
88  break;
90  message = "open failed";
91  break;
93  message = "missing statistics";
94  break;
96  message = "message read options conflict";
97  break;
99  message = "file has no message indices";
100  break;
101  default:
102  message = "unknown";
103  break;
104  }
105  }
106 
107  Status(StatusCode code, const std::string& message)
108  : code(code)
109  , message(message) {}
110 
111  bool ok() const {
112  return code == StatusCode::Success;
113  }
114 };
115 
116 } // namespace mcap
mcap::Status::Status
Status(StatusCode code)
Definition: errors.hpp:42
mcap::StatusCode::InvalidChunkOffset
@ InvalidChunkOffset
mcap::Status::message
std::string message
Definition: errors.hpp:37
mcap::StatusCode::InvalidFooter
@ InvalidFooter
mcap::Status
Wraps a status code and string message carrying additional context.
Definition: errors.hpp:35
mcap::StatusCode::DecompressionSizeMismatch
@ DecompressionSizeMismatch
mcap::StatusCode::NoMessageIndexesAvailable
@ NoMessageIndexesAvailable
mcap::StatusCode::InvalidMessageReadOptions
@ InvalidMessageReadOptions
mcap::StatusCode::ReadFailed
@ ReadFailed
mcap::Status::Status
Status()
Definition: errors.hpp:39
mcap::StatusCode::OpenFailed
@ OpenFailed
mcap::StatusCode::NotOpen
@ NotOpen
mcap::StatusCode::MagicMismatch
@ MagicMismatch
mcap::StatusCode::DecompressionFailed
@ DecompressionFailed
mcap::Status::ok
bool ok() const
Definition: errors.hpp:111
mcap
Definition: crc32.hpp:5
mcap::StatusCode::Success
@ Success
mcap::Status::Status
Status(StatusCode code, const std::string &message)
Definition: errors.hpp:107
mcap::StatusCode::InvalidFile
@ InvalidFile
mcap::StatusCode::InvalidRecord
@ InvalidRecord
mcap::StatusCode::FileTooSmall
@ FileTooSmall
mcap::StatusCode::UnrecognizedCompression
@ UnrecognizedCompression
mcap::Status::code
StatusCode code
Definition: errors.hpp:36
mcap::StatusCode::InvalidOpCode
@ InvalidOpCode
mcap::StatusCode::InvalidChannelId
@ InvalidChannelId
mcap::StatusCode::InvalidSchemaId
@ InvalidSchemaId
mcap::StatusCode
StatusCode
Status codes for MCAP readers and writers.
Definition: errors.hpp:10
mcap::StatusCode::MissingStatistics
@ MissingStatistics


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44