You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/project-docs/pages/migrating-sdk-code-to-3.n.adoc
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -308,8 +308,8 @@ In SDK 2 the main method to control transcoding was through providing different
308
308
This only worked for the KV APIs though -- Query, Search, Views, and other services exposed their JSON rows/hits in different ways.
309
309
All of this has been unified in SDK 3 under a single concept: serializers and transcoders.
310
310
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.
313
313
314
314
If you want to write already-encoded JSON, you would pass in the `RawJsonTranscoder` in the options block:
315
315
@@ -338,7 +338,7 @@ Here is a mapping table from the SDK 2 `Document<T>` and/or `IOperationResult<T>
338
338
|`byte[]` | `RawBinaryTranscoder`
339
339
|=======================
340
340
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.
342
342
343
343
Serializers and transcoders can also be customized and overwritten on a per-operation basis, please see the appropriate documentation section for details.
344
344
@@ -350,7 +350,8 @@ Usually there is no need to override it unless you want to provide your own impl
350
350
== Exception Handling
351
351
352
352
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.
354
355
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.
355
356
356
357
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
384
385
----
385
386
386
387
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.
390
391
391
392
[source,csharp]
392
393
----
@@ -521,9 +522,8 @@ The signatures now look very similar.
521
522
The concept of the `IDocument` as a type is gone in SDK 3 and instead you need to pass in the properties explicitly.
522
523
This makes it very clear what is returned, especially on the response side.
523
524
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.
527
527
528
528
Instead of having many overloads, all optional params are now part of the `Option` block.
529
529
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