This document outlines common error codes and their corresponding error messages that may occur in the Merchant app built with Flutter. It also includes a section to document the app's current handling of error codes.
Common Error Codes in Flutter
Below is a table of possible error codes and their corresponding error messages that developers may encounter while working with Flutter. These errors can occur during development, debugging, or runtime.
|
# |
Error Message |
Description |
|---|---|---|
|
|
|
A required plugin is not implemented or not found. |
|
|
|
An error occurred while communicating with the platform-specific code. |
|
|
|
A method or property is called on an object that does not support it. |
|
|
|
The data is not in the expected format (e.g., JSON parsing failed). |
|
|
|
A network or asynchronous operation timed out. |
|
|
|
A network-related error, such as failing to connect to a server. |
|
|
|
An error occurred while accessing the file system (e.g., file not found). |
|
|
|
The app is in an invalid state to perform the requested operation. |
|
|
|
An assertion failed during development. |
|
|
|
A value is outside the valid range (e.g., accessing an invalid index in a list). |
|
|
|
A value is not of the expected type. |
|
|
|
An invalid argument was passed to a function. |
|
|
|
The operation is not supported. |
|
|
|
A collection was modified while iterating over it. |
|
|
|
The call stack exceeded its limit (e.g., infinite recursion). |
|
|
|
The app ran out of memory. |
|
|
|
A widget exceeded the available space in the layout. |
|
|
|
A null value was accessed using the |
|
|
|
An error occurred while decoding a message from the platform channels. |
|
|
|
A specified asset (e.g., image, font) could not be loaded. |
|
|
|
An error occurred while making an HTTP request using the Dio package. |
|
|
|
An error occurred while interacting with Firebase services. |
|
|
|
The app does not have the required permissions to perform an operation. |
|
|
|
An invalid key was used (e.g., in encryption or Firebase). |
|
|
|
An error occurred while loading an image from the network. |
Notes on Error Codes
The table above does not cover all possible errors in Flutter. Here’s why:
-
Dart Language Errors: Dart can throw a wide variety of errors, including custom exceptions defined by developers.
-
Flutter Framework Errors: Errors related to widgets, rendering, and layout are specific to Flutter.
-
Platform-Specific Errors: Errors can occur due to platform-specific behavior (e.g., Android, iOS, web).
-
Plugin-Specific Errors: Plugins like Firebase, HTTP, or Camera can throw their own errors.
-
Tooling and Build Errors: Errors can occur during the build process or while using Flutter tools.
-
Custom Errors: Developers can define their own error classes, making the list of possible errors unbounded.
Current Handling of Error Codes in Merchant App
The Merchant app currently follows a strategy where error messages from the backend (BE) are displayed directly to the user in cases where the backend provides a specific error message. For example, if a login attempt fails, the app displays the exact error message returned by the API. This approach ensures consistency between the backend and frontend error messaging and provides users with clear and actionable feedback.
Key Characteristics of the Current System:
-
Backend-Driven Error Messages:
-
When the backend returns an error message (e.g., for login failures, validation errors, or API exceptions), the app displays the same message to the user.
-
Example: If the backend returns
"Invalid username or password", the app displays this exact message.
-
-
Generic Fallback for Unhandled Errors:
-
For errors that are not explicitly handled or do not include a backend-provided message, the app displays a generic error message such as "Something went wrong. Please try again later."
-
This ensures that users are not exposed to technical details or unhelpful error codes.
-
-
No Error Codes in UI:
-
Error codes are not shown to users in the UI. Instead, the focus is on providing clear and actionable messages.
-
-
Limited Centralized Error Handling:
-
While backend-driven error messages are displayed consistently, there is no centralized system for handling all errors across the app.
-
Error handling is implemented on a case-by-case basis, which can lead to inconsistencies in how errors are managed.
-
-
Reference to Backend Error Codes:
-
A draft Excel sheet documenting backend error codes and their corresponding messages is available for reference. This sheet is a work in progress and will be updated as the backend error-handling system evolves. https://youtap-my.sharepoint.com/:x:/p/elie_azzam/ETOZYpJYHgBAu8tPTCUJa2EBKlA8rX-2OVGLRRvsO3h65Q?wdOrigin=TEAMS-MAGLEV.p2p_ns.rwc&wdExp=TEAMS-TREATMENT&wdhostclicktime=1738051075877&web=1&clickparams=eyJBcHBOYW1lIjoiVGVhbXMtRGVza3RvcCIsIkFwcFZlcnNpb24iOiI1MC8yNDEyMDEwMDIyMSJ9
-