-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from mahdiramezanii/develop
Handel Erorr for users
- Loading branch information
Showing
7 changed files
with
98 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,44 @@ | ||
class ApiExceptiopn implements Exception{ | ||
import 'package:dio/dio.dart'; | ||
|
||
class ApiExceptiopn implements Exception { | ||
int code; | ||
String messgae; | ||
Response<dynamic>? response; | ||
ApiExceptiopn({required this.code, required this.messgae, this.response}) { | ||
if (code != 400) { | ||
return; | ||
} | ||
if (messgae == "Failed to authenticate.") { | ||
messgae = "نام کاربری یا رمز عبور اشتباه است"; | ||
} | ||
|
||
if (messgae == "Something went wrong while processing your request.") { | ||
messgae = "مقادیر ورودی نمیتواند خالی باشد!"; | ||
} | ||
|
||
if (messgae == "Failed to create record."){ | ||
|
||
if (response?.data["data"]["username"] != null){ | ||
|
||
if (response?.data["data"]["username"]["message"] == "The username is invalid or already in use."){ | ||
|
||
messgae = "نام کاربری تکراری است"; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
if (messgae == "Failed to create record."){ | ||
|
||
if (response?.data["data"]["passwordConfirm"] != null){ | ||
|
||
if (response?.data["data"]["passwordConfirm"]["message"] == "Values don't match."){ | ||
|
||
ApiExceptiopn({required this.code, required this.messgae}); | ||
messgae = "پسوردها شباهت ندارد"; | ||
} | ||
} | ||
} | ||
} | ||
} |