Skip to content

Commit cbbddb4

Browse files
fix/errors handling on transport
1 parent b8384ef commit cbbddb4

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@traceo-sdk/browser",
3-
"version": "0.31.9",
3+
"version": "0.31.14",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"license": "MIT",

packages/browser/src/transport/fetch.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export class FetchTransport<T> implements ITransport {
1414
body: JSON.stringify(this._options.body)
1515
};
1616

17-
await fetch(this._options.url, options);
17+
try {
18+
await fetch(this._options.url, options);
19+
} catch (error) {
20+
throw new Error(
21+
`[Traceo SDK] Cannot send data to Traceo Platform. Make sure the application is running. Caused by: ${error}`
22+
);
23+
}
1824
}
1925
}

packages/browser/src/transport/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ export class Transport {
1111
}
1212

1313
public send<T>(body: T, headers: Dictionary<string>) {
14-
try {
15-
const options = this.requestOptions<T>(body, headers);
16-
this.transport<T>(options).request();
17-
} catch (error) {
18-
console.log("Error sending data to traceo: ", error);
19-
}
14+
const options = this.requestOptions<T>(body, headers);
15+
this.transport<T>(options).request();
2016
}
2117

2218
private transport<T>(options: RequestOptions<T>) {

0 commit comments

Comments
 (0)