tryDecode method Null safety

dynamic tryDecode(
  1. Configuration configuration,
  2. String name,
  3. void decode(
      )
    )

    Implementation

    dynamic tryDecode(Configuration configuration, String name, void decode()) {
      try {
        return decode();
      } on ConfigurationException catch (e) {
        throw ConfigurationException(configuration, e.message,
            keyPath: [name]..addAll(e.keyPath));
      } on IntermediateException catch (e) {
        final underlying = e.underlying;
        if (underlying is ConfigurationException) {
          final keyPaths = [
            [name],
            e.keyPath,
            underlying.keyPath
          ].expand((i) => i).toList();
          throw ConfigurationException(configuration, underlying.message,
              keyPath: keyPaths);
        } else if (underlying is TypeError) {
          throw ConfigurationException(configuration, "input is wrong type",
              keyPath: [name]..addAll(e.keyPath));
        }
    
        throw ConfigurationException(configuration, underlying.toString(),
            keyPath: [name]..addAll(e.keyPath));
      } catch (e) {
        throw ConfigurationException(configuration, e.toString(),
            keyPath: [name]);
      }
    }