@@ -64,39 +64,47 @@ impl fmt::Display for AlignedError {
6464
6565#[ derive( Debug , Clone , Serialize , Deserialize ) ]
6666pub enum SubmitError {
67- // TODO: remove the GenericError and create an error for each case
68- GenericError ( String ) ,
67+ // General system-level errors
68+ GenericError ( String ) , // TODO: Replace with specific errors
6969 WebSocketConnectionError ( String ) ,
7070 WebSocketClosedUnexpectedlyError ( String ) ,
7171 IoError ( PathBuf , String ) ,
7272 SerializationError ( String ) ,
73+
74+ // Ethereum and cryptographic errors
7375 EthereumProviderError ( String ) ,
74- HexDecodingError ( String ) ,
7576 WalletSignerError ( String ) ,
77+ HexDecodingError ( String ) ,
78+ InvalidEthereumAddress ( String ) ,
79+ InvalidSignature ,
80+ InvalidChainId ,
81+
82+ // User input and validation errors
7683 MissingRequiredParameter ( String ) ,
7784 UnsupportedProvingSystem ( String ) ,
78- InvalidEthereumAddress ( String ) ,
7985 ProtocolVersionMismatch { current : u16 , expected : u16 } ,
80- BatchVerifiedEventStreamError ( String ) ,
81- BatchVerificationTimeout { timeout_seconds : u64 } ,
82- NoResponseFromBatcher ,
83- UnexpectedBatcherResponse ( String ) ,
84- EmptyVerificationDataCommitments ,
85- EmptyVerificationDataList ,
8686 InvalidNonce { sent : U256 , expected : U256 } ,
8787 InvalidMaxFee { sent : U256 , required : U256 } ,
88- ProofQueueFlushed ,
89- InvalidSignature ,
90- InvalidChainId ,
91- InvalidProof ( ProofInvalidReason ) ,
92- InvalidReplacementMessage ( ReplacementInvalidReason ) ,
9388 InsufficientBalance { available : U256 , required : U256 } ,
9489 BalanceUnlocked ,
90+ InvalidProof ( ProofInvalidReason ) ,
91+ InvalidReplacementMessage ( ReplacementInvalidReason ) ,
9592 InvalidPaymentServiceAddress { expected : H160 , received : H160 } ,
96- BatchSubmissionFailed ( String ) ,
93+
94+ // Batcher-related errors
95+ ProofQueueFlushed ,
9796 InvalidProofInclusionData ,
97+ EmptyVerificationDataCommitments ,
98+ EmptyVerificationDataList ,
9899 BatchQueueLimitExceeded ,
100+ BatchSubmissionFailed ( String ) ,
99101 BatcherUnexpectedError ,
102+
103+ // Batcher communication and response errors
104+ BatchVerifiedEventStreamError ( String ) ,
105+ BatchVerificationTimeout { timeout_seconds : u64 } ,
106+ NoResponseFromBatcher ,
107+ UnexpectedBatcherResponse ( String ) ,
100108}
101109
102110#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -161,118 +169,152 @@ impl fmt::Display for SubmitError {
161169 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
162170 match self {
163171 // General System-level Errors
164- SubmitError :: GenericError ( e) => write ! ( f, "Generic error: {}" , e) ,
172+ SubmitError :: GenericError ( e) => write ! ( f, "An unexpected error occurred : {}" , e) ,
165173 SubmitError :: WebSocketConnectionError ( e) => {
166- write ! ( f, "WebSocket connection error : {}" , e)
174+ write ! ( f, "Failed to establish WebSocket connection: {}" , e)
167175 }
168176 SubmitError :: WebSocketClosedUnexpectedlyError ( close_frame) => {
169- write ! ( f, "WebSocket closed unexpectedly: {}" , close_frame)
177+ write ! (
178+ f,
179+ "WebSocket connection closed unexpectedly: {}" ,
180+ close_frame
181+ )
170182 }
171183
172184 // Serialization Networking Errors
173- SubmitError :: IoError ( path, e) => write ! ( f, "IO error: {}: {}" , path. display( ) , e) ,
174- SubmitError :: SerializationError ( e) => write ! ( f, "Serialization error: {}" , e) ,
185+ SubmitError :: IoError ( path, e) => {
186+ write ! ( f, "Failed to access file '{}': {}" , path. display( ) , e)
187+ }
188+ SubmitError :: SerializationError ( e) => {
189+ write ! ( f, "Failed to serialize or deserialize data: {}" , e)
190+ }
175191
176192 // Ethereum Cryptographic Errors
177- SubmitError :: EthereumProviderError ( e) => write ! ( f, "Ethereum provider error: {}" , e) ,
178- SubmitError :: HexDecodingError ( e) => write ! ( f, "Hex decoding error: {}" , e) ,
179- SubmitError :: WalletSignerError ( e) => write ! ( f, "Wallet signer error: {}" , e) ,
193+ SubmitError :: EthereumProviderError ( e) => {
194+ write ! ( f, "Ethereum provider error: {}" , e)
195+ }
196+ SubmitError :: HexDecodingError ( e) => {
197+ write ! ( f, "Failed to decode hexadecimal value: {}" , e)
198+ }
199+ SubmitError :: WalletSignerError ( e) => {
200+ write ! ( f, "Error while signing transaction with wallet: {}" , e)
201+ }
180202 SubmitError :: InvalidEthereumAddress ( address) => {
181- write ! ( f, "Invalid Ethereum address: {}" , address)
203+ write ! ( f, "Invalid Ethereum address provided: {}" , address)
204+ }
205+ SubmitError :: InvalidSignature => {
206+ write ! ( f, "Signature verification failed. Please ensure the message was signed correctly." )
207+ }
208+ SubmitError :: InvalidChainId => {
209+ write ! (
210+ f,
211+ "Chain ID mismatch. Please check you're connected to the correct network."
212+ )
182213 }
183- SubmitError :: InvalidSignature => write ! ( f, "Invalid Signature" ) ,
184- SubmitError :: InvalidChainId => write ! ( f, "Invalid chain Id" ) ,
185214
186- // User Input Parameter Validation
215+ // User Input Parameter Validation Errors
187216 SubmitError :: MissingRequiredParameter ( param) => {
188- write ! ( f, "Missing required parameter: {} " , param)
217+ write ! ( f, "Missing required parameter: '{}' " , param)
189218 }
190219 SubmitError :: UnsupportedProvingSystem ( proving_system) => {
191- write ! ( f, "Unsupported proving system: {}" , proving_system)
220+ write ! ( f, "Unsupported proving system: '{}'" , proving_system)
221+ }
222+ SubmitError :: ProtocolVersionMismatch { current, expected } => {
223+ write ! (
224+ f,
225+ "Protocol version mismatch: current = {}, expected = {}" ,
226+ current, expected
227+ )
192228 }
193- SubmitError :: ProtocolVersionMismatch { current, expected } => write ! (
194- f,
195- "Protocol version mismatch: current={}, expected={}" ,
196- current, expected
197- ) ,
198229 SubmitError :: InvalidNonce { sent, expected } => {
199- write ! ( f, "Invalid nonce, sent: {}, required: {}" , sent, expected)
230+ write ! ( f, "Invalid nonce: sent = {}, expected = {}" , sent, expected)
231+ }
232+ SubmitError :: InvalidMaxFee { sent, required } => {
233+ write ! (
234+ f,
235+ "Max fee too low: sent = {} ETH, minimum required = {} ETH" ,
236+ format_ether( * sent) ,
237+ format_ether( * required)
238+ )
200239 }
201- SubmitError :: InvalidMaxFee { sent, required } => write ! (
202- f,
203- "Invalid max fee, sent: {}ether, required: {}ether" ,
204- format_ether( * sent) ,
205- format_ether( * required)
206- ) ,
207240 SubmitError :: InsufficientBalance {
208241 available,
209242 required,
210243 } => {
211244 write ! (
212245 f,
213- "Insufficient balance, available: {}ether , required {}ether " ,
246+ "Insufficient balance: available = {} ETH , required = {} ETH " ,
214247 format_ether( * available) ,
215248 format_ether( * required)
216249 )
217250 }
218251 SubmitError :: BalanceUnlocked => {
219- write ! ( f, "Balance is in batcher payment contract is unlocked" )
252+ write ! (
253+ f,
254+ "The balance in the batcher payment contract is currently unlocked."
255+ )
220256 }
221257 SubmitError :: InvalidProof ( reason) => {
222- write ! ( f, "Invalid proof, reason : {}" , reason)
258+ write ! ( f, "Invalid proof provided : {}" , reason)
223259 }
224260 SubmitError :: InvalidReplacementMessage ( reason) => {
225- write ! ( f, "Invalid replacement message, reason : {}" , reason)
261+ write ! ( f, "Invalid replacement request : {}" , reason)
226262 }
227263 SubmitError :: InvalidPaymentServiceAddress {
228264 received : received_addr,
229265 expected : expected_addr,
230266 } => {
231267 write ! (
232268 f,
233- "Invalid payment service address, received: {} , expected: {} " ,
269+ "Payment service address mismatch: received '{}' , expected '{}' " ,
234270 received_addr, expected_addr
235271 )
236272 }
237273
238274 // Batcher-related Errors
239275 SubmitError :: BatchVerifiedEventStreamError ( e) => {
240- write ! ( f, "Batch verified event stream error : {}" , e)
276+ write ! ( f, "Error while reading batch verification events : {}" , e)
241277 }
242278 SubmitError :: BatchVerificationTimeout { timeout_seconds } => {
243279 write ! (
244280 f,
245- "Batch verification timed out after {} seconds" ,
281+ "Timed out waiting for batch verification ( after {} seconds). " ,
246282 timeout_seconds
247283 )
248284 }
249- SubmitError :: NoResponseFromBatcher => write ! ( f, "No response received from batcher" ) ,
285+ SubmitError :: NoResponseFromBatcher => {
286+ write ! ( f, "No response received from the batcher." )
287+ }
250288 SubmitError :: UnexpectedBatcherResponse ( response) => {
251- write ! ( f, "Unexpected batcher response: {}" , response)
289+ write ! ( f, "Received unexpected response from batcher : {}" , response)
252290 }
253291 SubmitError :: EmptyVerificationDataCommitments => {
254- write ! ( f, "Verification data commitments are empty " )
292+ write ! ( f, "No verification data commitments were found. " )
255293 }
256294 SubmitError :: EmptyVerificationDataList => {
257- write ! ( f, "Verification data list is empty" )
295+ write ! ( f, "Verification data list is empty. Nothing to process. " )
258296 }
259- SubmitError :: BatchSubmissionFailed ( merkle_root) => write ! (
260- f,
261- "Could not create task with batch merkle root {}" ,
262- merkle_root
263- ) ,
264- SubmitError :: ProofQueueFlushed => write ! ( f, "Batch reset" ) ,
265- SubmitError :: InvalidProofInclusionData => {
266- write ! ( f, "Batcher responded with invalid batch inclusion data. Can't verify your proof was correctly included in the batch." )
297+ SubmitError :: BatchSubmissionFailed ( merkle_root) => {
298+ write ! (
299+ f,
300+ "Failed to submit batch with Merkle root '{}'." ,
301+ merkle_root
302+ )
267303 }
268- SubmitError :: BatchQueueLimitExceeded => {
304+ SubmitError :: ProofQueueFlushed => {
269305 write ! (
270306 f,
271- "Error while adding entry to batch, queue limit exceeded ."
307+ "Your proof was removed due to a batch reset. Please resubmit ."
272308 )
273309 }
310+ SubmitError :: InvalidProofInclusionData => {
311+ write ! ( f, "Batcher provided invalid inclusion data. Could not confirm your proof was included in the batch." )
312+ }
313+ SubmitError :: BatchQueueLimitExceeded => {
314+ write ! ( f, "Batch queue is full. Please try again later." )
315+ }
274316 SubmitError :: BatcherUnexpectedError => {
275- write ! ( f, "Batcher responded with an unexpected error " )
317+ write ! ( f, "An unexpected error occurred in the batcher. " )
276318 }
277319 }
278320 }
0 commit comments