MIGRATING.md in google-cloud-dialogflow-1.1.0 vs MIGRATING.md in google-cloud-dialogflow-1.1.1

- old
+ new

@@ -32,10 +32,14 @@ * Previously, the client included a method supporting bidirectional streaming recognition requests, both incremental audio and incremental results. The current client retains this method, but improves it with a more powerful interface to match streaming methods in other Ruby clients. See [Streaming Interface](#streaming-interface) for more info. + * Previously, clients reported RPC errors by raising instances of + `Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type + `Google::Cloud::Error` and its subclasses. See + [Handling Errors](#handling-errors) for more info. * Some classes have moved into different namespaces. See [Class Namespaces](#class-namespaces) for more info. ### Library Structure @@ -272,11 +276,11 @@ Finally, in the 1.0 client, you can also use the paths module as a convenience module. New: ``` -# Bring the session_path method into the current class +# Bring the path helper methods into the current class include Google::Cloud::Dialogflow::V2::Sessions::Paths def foo client = Google::Cloud::Dialogflow.sessions @@ -374,9 +378,53 @@ # Close the request stream when finished. request_stream.close # Wait for the response handling to finish response_thread.join +``` + +### Handling Errors + +The client reports standard +[gRPC error codes](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md) +by raising exceptions. In older releases, these exceptions were located in the +`Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base +exception class, defined in the `google-gax` gem. However, these classes were +different from the standard exceptions (subclasses of `Google::Cloud::Error`) +thrown by other client libraries such as `google-cloud-storage`. + +The 1.0 client library now uses the `Google::Cloud::Error` exception hierarchy, +for consistency across all the Google Cloud client libraries. In general, these +exceptions have the same name as their counterparts from older releases, but +are located in the `Google::Cloud` namespace rather than the `Google::Gax` +namespace. + +Old: +``` +client = Google::Cloud::Dialogflow::Sessions.new + +session = "projects/my-project/agent/sessions/my-session" +query = { text: { text: "book a meeting room", language_code: "en-US" } } + +begin + response = client.detect_intent session, query +rescue Google::Gax::Error => e + # Handle exceptions that subclass Google::Gax::Error +end +``` + +New: +``` +client = Google::Cloud::Dialogflow.sessions + +session = "projects/my-project/agent/sessions/my-session" +query = { text: { text: "book a meeting room", language_code: "en-US" } } + +begin + response = client.detect_intent session: session, query_input: query +rescue Google::Cloud::Error => e + # Handle exceptions that subclass Google::Cloud::Error +end ``` ### Class Namespaces In older releases, the client object was of classes with names like: