mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Merge branch 'master' into api-forms
This commit is contained in:
commit
fd818740f7
@ -1,6 +1,12 @@
|
|||||||
## InvenTree App Release Notes
|
## InvenTree App Release Notes
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### 0.2.9 - July 2021
|
||||||
|
---
|
||||||
|
|
||||||
|
- Handle 50x responses from server
|
||||||
|
- Improved reporting of error messages
|
||||||
|
|
||||||
### 0.2.8 - July 2021
|
### 0.2.8 - July 2021
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ export "COCOAPODS_PARALLEL_CODE_SIGN=true"
|
|||||||
export "FLUTTER_TARGET=lib\main.dart"
|
export "FLUTTER_TARGET=lib\main.dart"
|
||||||
export "FLUTTER_BUILD_DIR=build"
|
export "FLUTTER_BUILD_DIR=build"
|
||||||
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
|
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
|
||||||
export "FLUTTER_BUILD_NAME=0.2.8"
|
export "FLUTTER_BUILD_NAME=0.2.9"
|
||||||
export "FLUTTER_BUILD_NUMBER=16"
|
export "FLUTTER_BUILD_NUMBER=17"
|
||||||
export "DART_OBFUSCATION=false"
|
export "DART_OBFUSCATION=false"
|
||||||
export "TRACK_WIDGET_CREATION=false"
|
export "TRACK_WIDGET_CREATION=false"
|
||||||
export "TREE_SHAKE_ICONS=false"
|
export "TREE_SHAKE_ICONS=false"
|
||||||
|
52
lib/api.dart
52
lib/api.dart
@ -23,7 +23,7 @@ import 'package:inventree/widget/snacks.dart';
|
|||||||
*/
|
*/
|
||||||
class APIResponse {
|
class APIResponse {
|
||||||
|
|
||||||
APIResponse({this.url = "", this.method = "", this.statusCode = -1, this.data});
|
APIResponse({this.url = "", this.method = "", this.statusCode = -1, this.data = const {}});
|
||||||
|
|
||||||
int statusCode = -1;
|
int statusCode = -1;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ class APIResponse {
|
|||||||
|
|
||||||
String method = "";
|
String method = "";
|
||||||
|
|
||||||
dynamic data;
|
dynamic data = {};
|
||||||
|
|
||||||
// Request is "valid" if a statusCode was returned
|
// Request is "valid" if a statusCode was returned
|
||||||
bool isValid() => (statusCode >= 0) && (statusCode < 500);
|
bool isValid() => (statusCode >= 0) && (statusCode < 500);
|
||||||
@ -653,26 +653,32 @@ class InvenTreeAPI {
|
|||||||
HttpClientResponse? _response = await request.close().timeout(Duration(seconds: 10));
|
HttpClientResponse? _response = await request.close().timeout(Duration(seconds: 10));
|
||||||
|
|
||||||
response.statusCode = _response.statusCode;
|
response.statusCode = _response.statusCode;
|
||||||
response.data = await responseToJson(_response);
|
|
||||||
|
|
||||||
// Expected status code not returned
|
// If the server returns a server error code, alert the user
|
||||||
if ((statusCode != null) && (statusCode != _response.statusCode)) {
|
|
||||||
showStatusCodeError(_response.statusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Report any server errors
|
|
||||||
if (_response.statusCode >= 500) {
|
if (_response.statusCode >= 500) {
|
||||||
sentryReportMessage(
|
showStatusCodeError(_response.statusCode);
|
||||||
"Server error",
|
} else {
|
||||||
context: {
|
response.data = await responseToJson(_response) ?? {};
|
||||||
"url": request.uri.toString(),
|
|
||||||
"method": request.method,
|
// Expected status code not returned
|
||||||
"statusCode": _response.statusCode.toString(),
|
if ((statusCode != null) && (statusCode != _response.statusCode)) {
|
||||||
"requestHeaders": request.headers.toString(),
|
showStatusCodeError(_response.statusCode);
|
||||||
"responseHeaders": _response.headers.toString(),
|
}
|
||||||
"responseData": response.data.toString(),
|
|
||||||
}
|
// Report any server errors
|
||||||
);
|
if (_response.statusCode >= 500) {
|
||||||
|
sentryReportMessage(
|
||||||
|
"Server error",
|
||||||
|
context: {
|
||||||
|
"url": request.uri.toString(),
|
||||||
|
"method": request.method,
|
||||||
|
"statusCode": _response.statusCode.toString(),
|
||||||
|
"requestHeaders": request.headers.toString(),
|
||||||
|
"responseHeaders": _response.headers.toString(),
|
||||||
|
"responseData": response.data.toString(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} on SocketException catch (error) {
|
} on SocketException catch (error) {
|
||||||
@ -698,7 +704,7 @@ class InvenTreeAPI {
|
|||||||
try {
|
try {
|
||||||
var data = json.decode(body);
|
var data = json.decode(body);
|
||||||
|
|
||||||
return data;
|
return data ?? {};
|
||||||
} on FormatException {
|
} on FormatException {
|
||||||
|
|
||||||
print("JSON format exception!");
|
print("JSON format exception!");
|
||||||
@ -717,7 +723,9 @@ class InvenTreeAPI {
|
|||||||
L10().formatException,
|
L10().formatException,
|
||||||
L10().formatExceptionJson + ":\n${body}"
|
L10().formatExceptionJson + ":\n${body}"
|
||||||
);
|
);
|
||||||
return null;
|
|
||||||
|
// Return an empty map
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit 9cc07cdb0ec0012abcec827fc776d7c5473bb75e
|
Subproject commit 84f6ed3faf63cbf371016e134196400e5f822759
|
@ -128,10 +128,10 @@ Future<void> showServerError(String title, String description) async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> showStatusCodeError(int status, {int expected = 200}) async {
|
Future<void> showStatusCodeError(int status) async {
|
||||||
|
|
||||||
String msg = L10().responseInvalid;
|
String msg = L10().responseInvalid;
|
||||||
String extra = "Server responded with status code ${status}";
|
String extra = "${L10().statusCode}: ${status}";
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 400:
|
case 400:
|
||||||
@ -152,6 +152,24 @@ Future<void> showStatusCodeError(int status, {int expected = 200}) async {
|
|||||||
case 429:
|
case 429:
|
||||||
msg = L10().response429;
|
msg = L10().response429;
|
||||||
break;
|
break;
|
||||||
|
case 500:
|
||||||
|
msg = L10().response500;
|
||||||
|
break;
|
||||||
|
case 501:
|
||||||
|
msg = L10().response501;
|
||||||
|
break;
|
||||||
|
case 502:
|
||||||
|
msg = L10().response502;
|
||||||
|
break;
|
||||||
|
case 503:
|
||||||
|
msg = L10().response503;
|
||||||
|
break;
|
||||||
|
case 504:
|
||||||
|
msg = L10().response504;
|
||||||
|
break;
|
||||||
|
case 505:
|
||||||
|
msg = L10().response505;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ description: InvenTree stock management
|
|||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 0.2.8+16
|
version: 0.2.9+17
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user