File tree Expand file tree Collapse file tree 11 files changed +39
-20
lines changed
transaction/actions/gasless/providers Expand file tree Collapse file tree 11 files changed +39
-20
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " thirdweb " : patch
3
+ ---
4
+
5
+ Better error messages for failed requests
Original file line number Diff line number Diff line change @@ -60,8 +60,10 @@ export async function getErc721Tokens({
60
60
) ;
61
61
62
62
if ( ! response . ok ) {
63
- response . body ?. cancel ( ) ;
64
- console . error ( "Failed to fetch NFTs" ) ;
63
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
64
+ console . error (
65
+ `Failed to fetch NFTs: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
66
+ ) ;
65
67
return {
66
68
nextCursor : undefined ,
67
69
tokens : [ ] ,
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ export async function getChains() {
9
9
) ;
10
10
11
11
if ( ! response . ok ) {
12
- response . body ?. cancel ( ) ;
13
- throw new Error ( "Failed to fetch chains" ) ;
12
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
13
+ throw new Error (
14
+ `Failed to fetch chains: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
15
+ ) ;
14
16
}
15
17
16
18
return ( await response . json ( ) ) . data as ChainMetadata [ ] ;
Original file line number Diff line number Diff line change @@ -79,8 +79,10 @@ export async function getBuyWithCryptoHistory(
79
79
80
80
// Assuming the response directly matches the SwapResponse interface
81
81
if ( ! response . ok ) {
82
- response . body ?. cancel ( ) ;
83
- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
82
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
83
+ throw new Error (
84
+ `HTTP error! status: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
85
+ ) ;
84
86
}
85
87
86
88
const data : BuyWithCryptoHistoryData = ( await response . json ( ) ) . result ;
Original file line number Diff line number Diff line change @@ -142,8 +142,10 @@ export async function getBuyWithCryptoStatus(
142
142
143
143
// Assuming the response directly matches the BuyWithCryptoStatus interface
144
144
if ( ! response . ok ) {
145
- response . body ?. cancel ( ) ;
146
- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
145
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
146
+ throw new Error (
147
+ `HTTP error! status: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
148
+ ) ;
147
149
}
148
150
149
151
const data : BuyWithCryptoStatus = ( await response . json ( ) ) . result ;
Original file line number Diff line number Diff line change @@ -78,8 +78,10 @@ export async function getBuyWithFiatHistory(
78
78
79
79
// Assuming the response directly matches the BuyWithFiatStatus response interface
80
80
if ( ! response . ok ) {
81
- response . body ?. cancel ( ) ;
82
- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
81
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
82
+ throw new Error (
83
+ `HTTP error! status: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
84
+ ) ;
83
85
}
84
86
85
87
const data : BuyWithFiatHistoryData = ( await response . json ( ) ) . result ;
Original file line number Diff line number Diff line change @@ -188,8 +188,10 @@ export async function getBuyWithFiatStatus(
188
188
const response = await getClientFetch ( params . client ) ( url ) ;
189
189
190
190
if ( ! response . ok ) {
191
- response . body ?. cancel ( ) ;
192
- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
191
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
192
+ throw new Error (
193
+ `HTTP error! status: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
194
+ ) ;
193
195
}
194
196
195
197
return ( await response . json ( ) ) . result ;
Original file line number Diff line number Diff line change @@ -93,8 +93,10 @@ export async function getBuyHistory(
93
93
94
94
// Assuming the response directly matches the SwapResponse interface
95
95
if ( ! response . ok ) {
96
- response . body ?. cancel ( ) ;
97
- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
96
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
97
+ throw new Error (
98
+ `HTTP error! status: ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
99
+ ) ;
98
100
}
99
101
100
102
const data : BuyHistoryData = ( await response . json ( ) ) . result ;
Original file line number Diff line number Diff line change @@ -72,9 +72,9 @@ export async function fetchRpc(
72
72
} ) ;
73
73
74
74
if ( ! response . ok ) {
75
- response . body ?. cancel ( ) ;
75
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
76
76
throw new Error (
77
- `RPC request failed with status ${ response . status } - ${ response . statusText } ` ,
77
+ `RPC request failed with status ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
78
78
) ;
79
79
}
80
80
@@ -116,8 +116,10 @@ export async function fetchSingleRpc(
116
116
} ) ;
117
117
118
118
if ( ! response . ok ) {
119
- response . body ?. cancel ( ) ;
120
- throw new Error ( `RPC request failed with status ${ response . status } ` ) ;
119
+ const error = await response . text ( ) . catch ( ( ) => null ) ;
120
+ throw new Error (
121
+ `RPC request failed with status ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
122
+ ) ;
121
123
}
122
124
if ( response . headers . get ( "Content-Type" ) ?. startsWith ( "application/json" ) ) {
123
125
return await response . json ( ) ;
Original file line number Diff line number Diff line change @@ -139,7 +139,6 @@ export async function relayBiconomyTransaction(
139
139
} ,
140
140
) ;
141
141
if ( ! response . ok ) {
142
- response . body ?. cancel ( ) ;
143
142
throw new Error ( `Failed to send transaction: ${ await response . text ( ) } ` ) ;
144
143
}
145
144
const json = await response . json ( ) ;
Original file line number Diff line number Diff line change @@ -157,7 +157,6 @@ export async function relayOpenZeppelinTransaction(
157
157
} ) ;
158
158
159
159
if ( ! response . ok ) {
160
- response . body ?. cancel ( ) ;
161
160
throw new Error ( `Failed to send transaction: ${ await response . text ( ) } ` ) ;
162
161
}
163
162
const json = await response . json ( ) ;
You can’t perform that action at this time.
0 commit comments