Skip to content

Commit 8702caa

Browse files
Gardening from code review
Co-authored-by: Maria Shodunke <maria-robobug@users.noreply.github.com>
1 parent 6203d78 commit 8702caa

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

modules/project-docs/pages/migrating-sdk-code-to-3.n.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ In SDK 2 the main method to control transcoding was through providing different
308308
This only worked for the KV APIs though -- Query, Search, Views, and other services exposed their JSON rows/hits in different ways.
309309
All of this has been unified in SDK 3 under a single concept: serializers and transcoders.
310310

311-
By default, all KV APIs transcode to and from JSON either with `dynamic` objects or POCOs. In general this will suffice for the vast number of use cases, however,
312-
sometimes another transcoder will be needed.
311+
By default, all KV APIs transcode to and from JSON either with `dynamic` objects or POCOs.
312+
In general this will suffice for the vast number of use cases, however, sometimes another transcoder will be needed.
313313

314314
If you want to write already-encoded JSON, you would pass in the `RawJsonTranscoder` in the options block:
315315

@@ -338,7 +338,7 @@ Here is a mapping table from the SDK 2 `Document<T>` and/or `IOperationResult<T>
338338
|`byte[]` | `RawBinaryTranscoder`
339339
|=======================
340340

341-
*Note that .NET SDK 2 had a DefaultTranscoder for storing JSON, a BinaryTranscoder for storing binary content and a BinaryToJsonTranscoder for handling legacy upgrades from very early server versions.
341+
*Note that .NET SDK 2 had a `DefaultTranscoder` for storing JSON, a `BinaryTranscoder` for storing binary content and a `BinaryToJsonTranscoder` for handling legacy upgrades from very early server versions.
342342

343343
Serializers and transcoders can also be customized and overwritten on a per-operation basis, please see the appropriate documentation section for details.
344344

@@ -350,7 +350,8 @@ Usually there is no need to override it unless you want to provide your own impl
350350
== Exception Handling
351351

352352
While how to _handle_ exceptions is unchanged from SDK 2, using a try/catch clause, the way common errors are exposed to the application layer by SDK3 is significantly different.
353-
In SDK2, exceptions are not thrown for most operations, only for terminal failures within the SDK. Instead an `IResult` implementation was returned which contained a `Success`, `Status` and `Exception` fields.
353+
In SDK2, exceptions are not thrown for most operations, only for terminal failures within the SDK.
354+
Instead an `IResult` implementation was returned which contained a `Success`, `Status` and `Exception` fields.
354355
In SDK3, this has changed and now all errors are thrown from the SDK (as well as terminal failures) and must be handled by the application code.
355356

356357
There have been changes made in the following areas:
@@ -384,9 +385,9 @@ Besides the stacktrace and exception message, there is also additional context i
384385
----
385386

386387
The expectation is that the application catches the `CouchbaseException` and deals with it as an unexpected error (e.g. logging with subsequent bubbling up of the exception or failing).
387-
In addition to that, each method exposes exceptions that can be caught separately if needed. For example, a `GetAsync()` may throw a `DocumentNotFoundException` or a
388-
`TimeoutException` in addition to a more generic `CouchbaseException`.These exceptions extend `CouchbaseException`, but both the `TimeoutException` and the
389-
`DocumentNotFoundException` can be caught individually if specific logic should be executed to handle them.
388+
In addition to that, each method exposes exceptions that can be caught separately if needed.
389+
For example, a `GetAsync()` may throw a `DocumentNotFoundException` or a `TimeoutException` in addition to a more generic `CouchbaseException`.
390+
These exceptions extend `CouchbaseException`, but both the `TimeoutException` and the `DocumentNotFoundException` can be caught individually if specific logic should be executed to handle them.
390391

391392
[source,csharp]
392393
----
@@ -521,9 +522,8 @@ The signatures now look very similar.
521522
The concept of the `IDocument` as a type is gone in SDK 3 and instead you need to pass in the properties explicitly.
522523
This makes it very clear what is returned, especially on the response side.
523524

524-
Thus, the `GetAsync` method does not return a `IDocumentResult` or a `IOperationResult` but a `IGetResult` instead, and the `UpsertAsync` does not return a
525-
`IDocumentResult` or a `IOperationResult` but a `IMutationResult`. Each of those results only contain the field that the specific method can actually return,
526-
making it impossible to accidentally try to access the `expiry` on the `IDocumentResult` after a mutation, for example.
525+
Thus, the `GetAsync` method does not return a `IDocumentResult` or a `IOperationResult` but a `IGetResult` instead, and the `UpsertAsync` does not return a `IDocumentResult` or a `IOperationResult` but a `IMutationResult`.
526+
Each of those results only contain the field that the specific method can actually return, making it impossible to accidentally try to access the `expiry` on the `IDocumentResult` after a mutation, for example.
527527

528528
Instead of having many overloads, all optional params are now part of the `Option` block.
529529
All required params are still part of the method signature, making it clear what is required and what is not (or has default values applied if not overridden).

0 commit comments

Comments
 (0)