Skip to content

Commit 49e851c

Browse files
fix: error fields show Unknown error (#75)
1 parent db6e9f6 commit 49e851c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.changeset/every-months-open.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@s2-dev/streamstore": minor
3+
---
4+
5+
Fix error messages to contain more info

packages/streamstore/src/s2.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { S2AccessTokens } from "./accessTokens.js";
22
import { S2Basin } from "./basin.js";
33
import { S2Basins } from "./basins.js";
44
import type { RetryConfig, S2ClientOptions } from "./common.js";
5-
import { S2Error } from "./error.js";
5+
import { makeServerError } from "./error.js";
66
import { createClient, createConfig } from "./generated/client/index.js";
77
import type { Client } from "./generated/client/types.gen.js";
88
import * as Redacted from "./lib/redacted.js";
@@ -59,12 +59,8 @@ export class S2 {
5959
}),
6060
);
6161

62-
this.client.interceptors.error.use((err, res, req, opt) => {
63-
return new S2Error({
64-
message: err instanceof Error ? err.message : "Unknown error",
65-
status: res.status,
66-
origin: "server",
67-
});
62+
this.client.interceptors.error.use((err, res) => {
63+
return makeServerError(res, err);
6864
});
6965

7066
this.basins = new S2Basins(this.client, this.retryConfig);

0 commit comments

Comments
 (0)