MIGRATING.md in google-cloud-scheduler-2.1.0 vs MIGRATING.md in google-cloud-scheduler-2.1.1

- old
+ new

@@ -28,10 +28,14 @@ [Passing Arguments](#passing-arguments) for more info. * Previously, some client classes included helper methods for constructing resource paths. These methods now take keyword rather than positional arguments, and are also available in a separate paths module. See [Resource Path Helpers](#resource-path-helpers) 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 @@ -239,11 +243,11 @@ In the 2.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::Scheduler::V1::CloudScheduler::Paths def foo client = Google::Cloud::Scheduler.cloud_scheduler @@ -251,9 +255,51 @@ parent = location_path project: "my-project", location: "-" response = client.list_jobs parent: parent # Do something with response... +end +``` + +### 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 2.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::Scheduler.new + +parent = "projects/my-project/locations/-" + +begin + response = client.list_jobs parent, page_size: 10 +rescue Google::Gax::Error => e + # Handle exceptions that subclass Google::Gax::Error +end +``` + +New: +``` +client = Google::Cloud::Scheduler.cloud_scheduler + +parent = "projects/my-project/locations/-" + +begin + response = client.list_jobs parent: parent, page_size: 10 +rescue Google::Cloud::Error => e + # Handle exceptions that subclass Google::Cloud::Error end ``` ### Class Namespaces