ErrorListner function

Future<void> ErrorListner({
  1. dynamic apiname,
  2. dynamic request,
  3. dynamic responsed,
  4. dynamic app_error,
})

Implementation

Future<void> ErrorListner({apiname, request, responsed, app_error}) async {
  try {
    // Send error log to your API
    http.Response response = await http.post(
      Uri.parse('${BASE_URL}app_log'),
      body: {
        "apiname": '${WELLNESS_URL}${apiname}',
        "token": '$currentUserToken',
        "request": request ?? '',
        "response": responsed ?? '',
        "app_error": app_error ?? '',
      },
    );

    var decodedResponse = json.decode(response.body);

    await _sendErrorEmail(
      apiname: apiname,
      request: request,
      response: responsed,
      appError: app_error,
    );
  } catch (e) {
    print("Error in ErrorListner: $e");
  }
}