close method

String close(
  1. Danger<Object, Exception> danger,
  2. bool flag,
  3. Log log
)

すべての log を含めるか, 最終的な結果だけを返すかを分岐.

Implementation

String close(Danger danger, bool flag, Log log) {

    switch (flag) {
    case true:

        log.add(danger);

        final result = BpriverYaml.logToMoldYamlString(log);
        if (result is! Success<String, BpriverYamlExceptionI>) Result.panic(CitrusResponseErrorA(), log);

        return result.wrapped;

    case false:

        List<String> message = [];
        final wrapped = danger.wrapped;
        if (wrapped is LoggerResultMessageSignature) message = wrapped.loggerResultMessage;

        final history = History(
            wrapped.runtimeType.toString(),
            message,
            danger.log.classLocation,
            danger.log.functionLocation,
            danger.log.getMonitor(),
            danger.log.getDebug(),
            [],
        );

        final result = BpriverYaml.toYamlString(history.mold());
        if (result is! Success<String, BpriverYamlExceptionI>) Result.panic(CitrusResponseErrorA(), log);

        return result.wrapped;

    }

}