Skip to content

Commit 45dcd74

Browse files
Aristidis Papaioannoufacebook-github-bot
authored andcommitted
Augment thrift.ExceptionMessage docs (#591)
Summary: Pull Request resolved: facebook/fbthrift#591 Reviewed By: thedavekwon Differential Revision: D52861937 fbshipit-source-id: d9dc88d32f338c0ecd193242b4b93840a4783310
1 parent 654dafb commit 45dcd74

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

third-party/thrift/src/thrift/annotation/thrift.thrift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ struct BitmaskEnum {}
167167

168168
/**
169169
* Specifies the field where the exception message is stored.
170+
*
171+
* The "exception message" is typically a human-readable description of the
172+
* exception. It is made available to the exception-handling code via standard,
173+
* language-dependent APIs of the generated code, such as:
174+
* - [`std::exception::what()`](https://en.cppreference.com/w/cpp/error/exception/what)
175+
* in C++.
176+
* - [`Throwable.getMessage()`](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#getMessage--)
177+
* in Java.
178+
* - etc.
179+
*
180+
* This annotation can be specified on at most one field of an
181+
* [exception definition](https://github.com/facebook/fbthrift/blob/main/thrift/doc/idl/index.md#exceptions),
182+
* whose type must be `string`.
183+
*
184+
* If an exception definition does not specify this anotation for any field, the
185+
* exception message returned by the aforementioned APIs is unspecified.
170186
*/
171187
@scope.Field
172188
struct ExceptionMessage {}

third-party/thrift/src/thrift/doc/features/exception.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ A **declared** exception is an exception struct defined in IDL. Interfaces can d
1313

1414
An **undeclared** exception is thrown by Thrift methods that are wrapped into a generic [TApplicationException](https://github.com/facebook/fbthrift/blob/main/thrift/lib/cpp/TApplicationException.h) or [TTransportException](https://github.com/facebook/fbthrift/blob/main/thrift/lib/cpp/transport/TTransportException.h) and passed to the client. It is similar to throwing generic exceptions (e.g. `Exception` or `std::exception`) and is generally discouraged since it is too general to carry sufficient information. It is highly encouraged to avoid as much as possible throwing undeclared exceptions.
1515

16+
### Exception Message
17+
18+
A custom (human-readable) exception message may be specified in a field, by
19+
annotating it with
20+
[`@thrift.ExceptionMessage`](/idl/annotations.md#thrift-annotations).
21+
1622
## Error Classification
1723
### Kind
1824
Thrift Error can be classified into three categories: **Transient**, **Stateful**, and **Permanent**.

0 commit comments

Comments
 (0)