Skip to content

[cloud_functions] HttpsCallable.call throws PlatformException instead of CloudFunctionsException #2069

@punkeroso

Description

@punkeroso

Describe the bug
When calling .call trying to get an error (i.e. with wrong parameters, wrong function name or wrong region) I'm getting a PlatformException instead of a CloudFunctionsException

To Reproduce
This is the function that actually call .call

Future<num> _simpleFunction(String param1, String param2) async {
    final HttpsCallable _simpleFunction =
        CloudFunctions(region: "europe-west1")
            .getHttpsCallable(functionName: 'simpleFunction');

    try {
      final HttpsCallableResult response = await _addUserRemainder
          .call(<String, dynamic>{'param1': param1, 'param2': param2});

      return response.data['result'];
    } on CloudFunctionsException catch (e) {
      print('catched $e');
      rethrow;
    }
}

And this is where I call _simpleFunction

try {
        num balance;
          balance =
              await _simpleFunction('param', 'param2');
        }
      } catch (error) {
        print('Main block $error');
      }

And I always get:
I/flutter (10343): Main block PlatformException(functionsError, Cloud function failed with exception., {code: INVALID_ARGUMENT, details: null, message: Invalid QR code})

Expected behavior
Reading the implementation of .call function, it should always return a CloudFunctionsException instead.

Additional context
cloud_functions version is 0.4.2

Till the version 0.4.1+6 was working fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: customerA bug with low impact (e.g. affecting only a few customers or has a workaround). (P3)plugin: functionstype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions