Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
LocalException.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_LOCAL_EXCEPTION_H
4#define ICE_LOCAL_EXCEPTION_H
5
6#include "Exception.h"
7
8#include <memory>
9#include <string>
10#include <vector>
11
12namespace Ice
13{
14 /// Base class for all Ice exceptions not defined in Slice.
15 /// @headerfile Ice/Ice.h
16 class ICE_API LocalException : public Exception
17 {
18 public:
19 /// Constructs a local exception.
20 /// @param file The file where this exception is constructed. This C string is not copied.
21 /// @param line The line where this exception is constructed.
22 /// @param message The error message adopted by this exception and returned by what().
23 LocalException(const char* file, int line, std::string message);
24
25 /// Gets the error message of this local Ice exception.
26 /// @return The error message.
27 [[nodiscard]] const char* what() const noexcept final;
28
29 void ice_print(std::ostream& os) const final;
30
31 [[nodiscard]] const char* ice_id() const noexcept override;
32
33 /// Gets the name of the file where this exception was constructed.
34 /// @return The file name.
35 [[nodiscard]] const char* ice_file() const noexcept;
36
37 /// Gets the line number where this exception was constructed.
38 /// @return The line number.
39 [[nodiscard]] int ice_line() const noexcept;
40
41 /// Gets the stack trace at the point this exception was constructed.
42 /// @return The stack trace as a string, or an empty string if stack trace collection is not enabled.
43 [[nodiscard]] std::string ice_stackTrace() const;
44
45 /// Enables the collection of stack traces for exceptions. On Windows, calling this function more than once is
46 /// useful to refresh the symbol module list; on other platforms, the second and subsequent calls have no
47 /// effect.
49
50 private:
51 const char* _file;
52 int _line;
53 std::shared_ptr<std::string> _whatString; // shared storage for custom _what message.
54 std::shared_ptr<std::vector<void*>> _stackFrames; // shared storage for stack frames.
55 };
56}
57
58#endif
Exception() noexcept=default
Default constructor.
const char * what() const noexcept final
Gets the error message of this local Ice exception.
const char * ice_file() const noexcept
Gets the name of the file where this exception was constructed.
void ice_print(std::ostream &os) const final
Outputs a description of this exception to a stream.
static void ice_enableStackTraceCollection()
Enables the collection of stack traces for exceptions.
std::string ice_stackTrace() const
Gets the stack trace at the point this exception was constructed.
int ice_line() const noexcept
Gets the line number where this exception was constructed.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
The Ice RPC framework.
Definition SampleEvent.h:59