Skip to content

Commit 60b81b6

Browse files
authored
Release (#208)
2 parents bc5d456 + 4d87da8 commit 60b81b6

35 files changed

+691
-77
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nitric/sdk",
33
"description": "Nitric NodeJS client sdk",
4-
"nitric": "v0.32.0",
4+
"nitric": "v0.33.0",
55
"author": "Nitric <https://github.com/nitrictech>",
66
"repository": "https://github.com/nitrictech/node-sdk",
77
"main": "lib/index.js",
@@ -32,6 +32,7 @@
3232
],
3333
"dependencies": {
3434
"@grpc/grpc-js": "1.8.1",
35+
"@nitric/grpc-error-status": "^0.0.2",
3536
"@opentelemetry/api": "^1.4.1",
3637
"@opentelemetry/exporter-trace-otlp-http": "^0.36.1",
3738
"@opentelemetry/instrumentation": "^0.36.1",

src/api/documents/v0/collection-group-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class CollectionGroupRef<T extends DocumentStructure> {
5050
name: string
5151
): CollectionGroupRef<T> {
5252
if (this.depth() >= MAX_COLLECTION_DEPTH) {
53-
throw new InvalidArgumentError(
53+
throw new Error(
5454
`Maximum collection depth ${MAX_COLLECTION_DEPTH} exceeded`
5555
);
5656
}

src/api/documents/v0/document-ref.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe('Document Ref Tests', () => {
176176
const testNestedAgain = () => nestedCollection.collection('nested-again');
177177

178178
expect(testNestedAgain).toThrow(
179-
new InvalidArgumentError('Maximum collection depth 1 exceeded')
179+
new Error('Maximum collection depth 1 exceeded')
180180
);
181181
});
182182
});

src/api/documents/v0/document-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class DocumentRef<T extends DocumentStructure> {
143143
name: string
144144
): CollectionRef<T> {
145145
if (this.depth() >= MAX_COLLECTION_DEPTH) {
146-
throw new InvalidArgumentError(
146+
throw new Error(
147147
`Maximum collection depth ${MAX_COLLECTION_DEPTH} exceeded`
148148
);
149149
}

src/api/documents/v0/query.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ describe('Query Tests', () => {
200200

201201
q.pagingFrom('test' as any);
202202

203-
await expect(q.fetch()).rejects.toStrictEqual(
204-
new InvalidArgumentError('Invalid paging token provided!')
203+
await expect(q.fetch()).rejects.toEqual(
204+
new Error('Invalid paging token provided!')
205205
);
206206
});
207207
});

src/api/documents/v0/query.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ export class Query<T extends DocumentStructure> {
139139
*/
140140
public limit(limit: number): Query<T> {
141141
if (typeof limit !== 'number' || limit < 0) {
142-
throw new InvalidArgumentError(
143-
'limit must be a positive integer or 0 for unlimited.'
144-
);
142+
throw new Error('limit must be a positive integer or 0 for unlimited.');
145143
}
146144

147145
this.fetchLimit = limit;
@@ -160,7 +158,7 @@ export class Query<T extends DocumentStructure> {
160158

161159
if (this.pagingToken != null) {
162160
if (!(this.pagingToken instanceof Map)) {
163-
throw new InvalidArgumentError('Invalid paging token provided!');
161+
throw new Error('Invalid paging token provided!');
164162
}
165163

166164
const map = request.getPagingTokenMap();

src/api/errors/aborted.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
14+
import { ErrorDetails } from '@nitric/sdk/gen/proto/error/v1/error_pb';
15+
import { NitricPluginError } from './plugin-error';
1516
/**
1617
* AbortedError
1718
*
1819
* The operation was aborted
1920
*/
20-
export class AbortedError extends Error {
21-
constructor(message: string) {
22-
super(message);
21+
export class AbortedError extends NitricPluginError {
22+
constructor(message: string, details: ErrorDetails) {
23+
super(message, details);
2324
Object.setPrototypeOf(this, AbortedError.prototype);
2425
}
2526
}

src/api/errors/already-exists.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import { ErrorDetails } from '@nitric/sdk/gen/proto/error/v1/error_pb';
16+
import { NitricPluginError } from './plugin-error';
17+
1518
/**
1619
* AlreadyExistsError
1720
*
1821
* Client attempted to illegally create an entity that already exists
1922
*/
20-
export class AlreadyExistsError extends Error {
21-
constructor(message: string) {
22-
super(message);
23+
export class AlreadyExistsError extends NitricPluginError {
24+
constructor(message: string, details: ErrorDetails) {
25+
super(message, details);
2326
Object.setPrototypeOf(this, AlreadyExistsError.prototype);
2427
}
2528
}

src/api/errors/cancelled.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import {
16+
ErrorDetails,
17+
ErrorScope,
18+
} from '@nitric/sdk/gen/proto/error/v1/error_pb';
19+
import { NitricPluginError } from './plugin-error';
20+
1521
/**
1622
* CancelledError
1723
*
1824
* Operation was cancelled (typically occurs client side)
1925
*/
20-
export class CancelledError extends Error {
21-
constructor(message: string) {
22-
super(message);
26+
export class CancelledError extends NitricPluginError {
27+
constructor(message: string, details: ErrorDetails) {
28+
super(message, details);
2329
Object.setPrototypeOf(this, CancelledError.prototype);
2430
}
2531
}

src/api/errors/data-loss.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import { ErrorDetails } from '@nitric/sdk/gen/proto/error/v1/error_pb';
16+
import { NitricPluginError } from './plugin-error';
17+
1518
/**
1619
* DataLossError
1720
*
1821
* Unrecoverable data loss or corruption
1922
*/
20-
export class DataLossError extends Error {
21-
constructor(message: string) {
22-
super(message);
23+
export class DataLossError extends NitricPluginError {
24+
constructor(message: string, details: ErrorDetails) {
25+
super(message, details);
2326
Object.setPrototypeOf(this, DataLossError.prototype);
2427
}
2528
}

0 commit comments

Comments
 (0)