@@ -7,6 +7,7 @@ import ChainsService from '../services/ChainsService'
7
7
import {
8
8
LifiError ,
9
9
LifiErrorCode ,
10
+ MetaMaskProviderErrorCode ,
10
11
NotFoundError ,
11
12
ProviderError ,
12
13
RPCError ,
@@ -152,40 +153,45 @@ export const parseError = async (
152
153
)
153
154
}
154
155
}
156
+ }
155
157
156
- if ( e . code === 'CALL_EXCEPTION' ) {
158
+ switch ( e . code ) {
159
+ case 'CALL_EXCEPTION' :
157
160
return new ProviderError (
158
161
LifiErrorCode . TransactionFailed ,
159
162
e . reason ,
160
163
await getTransactionNotSentMessage ( step , process ) ,
161
164
e . stack
162
165
)
163
- }
164
-
165
- if ( e . code === LifiErrorCode . TransactionUnprepared ) {
166
+ case 'ACTION_REJECTED' :
167
+ case MetaMaskProviderErrorCode . userRejectedRequest :
168
+ return new TransactionError (
169
+ LifiErrorCode . TransactionRejected ,
170
+ e . message ,
171
+ await getTransactionNotSentMessage ( step , process ) ,
172
+ e . stack
173
+ )
174
+ case LifiErrorCode . TransactionUnprepared :
166
175
return new TransactionError (
167
176
LifiErrorCode . TransactionUnprepared ,
168
177
e . message ,
169
178
await getTransactionNotSentMessage ( step , process ) ,
170
179
e . stack
171
180
)
172
- }
173
-
174
- if ( e . code === LifiErrorCode . ValidationError ) {
181
+ case LifiErrorCode . ValidationError :
175
182
return new TransactionError (
176
183
LifiErrorCode . ValidationError ,
177
184
e . message ,
178
185
e . htmlMessage
179
186
)
180
- }
187
+ default :
188
+ return new UnknownError (
189
+ LifiErrorCode . InternalError ,
190
+ e . message || 'Unknown error occurred.' ,
191
+ undefined ,
192
+ e . stack
193
+ )
181
194
}
182
-
183
- return new UnknownError (
184
- LifiErrorCode . InternalError ,
185
- e . message || 'Unknown error occurred.' ,
186
- undefined ,
187
- e . stack
188
- )
189
195
}
190
196
191
197
export const parseBackendError = ( e : any ) : LifiError => {
0 commit comments