Skip to content

Commit f21e777

Browse files
authored
Merge pull request #64 from kaleido-io/idempotency
Add unique exception for idempotency conflicts
2 parents 7747948 + 9abe619 commit f21e777

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

lib/firefly.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ export default class FireFly extends HttpBase {
510510
return this.getMany<FireFlyContractListenerResponse[]>('/contracts/listeners', filter, options);
511511
}
512512

513+
async deleteContractListener(id: string, options?: FireFlyDeleteOptions) {
514+
await this.deleteOne(`/contracts/listeners/${id}`, options);
515+
}
516+
513517
getContractAPIListeners(
514518
apiName: string,
515519
eventPath: string,

lib/http.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
FireFlyReplaceOptions,
99
FireFlyUpdateOptions,
1010
FireFlyDeleteOptions,
11+
FireFlyIdempotencyError,
1112
} from './interfaces';
1213

1314
function isSuccess(status: number) {
@@ -74,8 +75,12 @@ export default class HttpBase {
7475
protected async wrapError<T>(response: Promise<AxiosResponse<T>>) {
7576
return response.catch((err) => {
7677
if (axios.isAxiosError(err)) {
77-
const errorMessage = err.response?.data?.error;
78-
const ffError = new FireFlyError(errorMessage ?? err.message, err, err.request.path);
78+
const errorMessage = err.response?.data?.error ?? err.message;
79+
const errorClass =
80+
errorMessage?.includes('FF10430') || errorMessage?.includes('FF10431')
81+
? FireFlyIdempotencyError
82+
: FireFlyError;
83+
const ffError = new errorClass(errorMessage, err, err.request.path);
7984
if (this.errorHandler !== undefined) {
8085
this.errorHandler(ffError);
8186
}

lib/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class FireFlyError extends Error {
2121
}
2222
}
2323

24+
export class FireFlyIdempotencyError extends FireFlyError {}
25+
2426
interface FireFlyBaseHttpOptions {
2527
requestConfig?: AxiosRequestConfig;
2628
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hyperledger/firefly-sdk",
3-
"version": "1.2.6",
3+
"version": "1.2.7",
44
"description": "Client SDK for Hyperledger FireFly",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)