Skip to content

Commit

Permalink
Merge pull request #2626 from AlphaWallet/tweak-error-logging4
Browse files Browse the repository at this point in the history
Tweak error logging to be more granular
  • Loading branch information
vladyslav-iosdev authored Mar 9, 2021
2 parents 7bcab25 + cd4877e commit 11443dc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions AlphaWallet/Extensions/Session+PromiseKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ struct NonceTooLowError: LocalizedError {
"The nonce of the transaction is too low"
}
}
struct GasPriceTooLow: LocalizedError {
var errorDescription: String? {
//TODO remove after mapping to better UI and message. Hence not localized yet
"The gas price specified for this transaction is too low"
}
}
struct GasLimitTooLow: LocalizedError {
var errorDescription: String? {
//TODO remove after mapping to better UI and message. Hence not localized yet
"The gas limit specified for this transaction is too low"
}
}
struct NetworkConnectionWasLostError: LocalizedError {
var errorDescription: String? {
//TODO remove after mapping to better UI and message. Hence not localized yet
Expand Down Expand Up @@ -109,6 +121,12 @@ extension Session {
} else if message.lowercased().hasPrefix("nonce too low") {
RemoteLogger.instance.logRpcOrOtherWebError("JSONRPCError.responseError | code: \(code) | message: \(message) | as: NonceTooLowError()", url: baseUrl.absoluteString)
return NonceTooLowError()
} else if message.lowercased().hasPrefix("transaction underpriced") {
RemoteLogger.instance.logRpcOrOtherWebError("JSONRPCError.responseError | code: \(code) | message: \(message) | as: GasPriceTooLow()", url: baseUrl.absoluteString)
return GasPriceTooLow()
} else if message.lowercased().hasPrefix("intrinsic gas too low") {
RemoteLogger.instance.logRpcOrOtherWebError("JSONRPCError.responseError | code: \(code) | message: \(message) | as: GasLimitTooLow()", url: baseUrl.absoluteString)
return GasLimitTooLow()
} else {
RemoteLogger.instance.logRpcOrOtherWebError("JSONRPCError.responseError | code: \(code) | message: \(message)", url: baseUrl.absoluteString)
}
Expand Down

0 comments on commit 11443dc

Please sign in to comment.