performOperation method

  1. @override
void performOperation(
  1. ModSessionDTO dto
)
override

Abstraction to perform some operation using params received. Must be overriden by children.

Implementation

@override
void performOperation(ModSessionDTO dto) async {

  var res;
  try {
    var data = await this.callAuthentication(dto);

    // DATA
    if (data != null) {
      res = this.buildResult(data: data);

    // ERROR
    } else {
      throw Exception();
    }

  } on ModDataException catch (lde) {
    ModLogger.e(tag: TAG, msg: "${lde.toString()}");

    res = this.buildResult(data: null, code:lde.code ?? this.getErrorCode());

  } on PlatformException catch (pe) {
    ModLogger.e(tag: TAG, msg: "${pe.toString()}");

    res = this.buildResult(data: null, code: this.getErrorCode(e: pe));

  } on Exception catch (e) {
    ModLogger.e(tag: TAG, msg: "${e.toString()}");

    res = this.buildResult(data: null, code: this.getErrorCode());

  } finally {
    this.processData(res);
  }
}