如何处理包含在内的-21,-103无效值:Dart中不在RangeError范围内?

时间:2019-01-26 10:47:12

标签: error-handling socket.io dart range aqueduct

我有一个已使用一年的套接字应用程序。一个用户数据似乎超出范围。用户不断包含-21,-103无效值:不在RangeError范围内。

错误字符串: RangeError(长度):无效值:不在范围0..576460752303423487中,包括:-103

如何处理包含在内的-21,-103无效值:Dart中不在RangeError范围内?

try {
  String _reply = “”;

    socket = await Socket.connect('192.168.1.10’, 8080);
    socket.write('Server__Query__Part\r\n');

    socket.handleError((data) {
      print(data);
    }

    await for (var data in socket) {
      _reply = new String.fromCharCodes(data).trim();
      socket.close();
      socket.destroy();
    }
  } 
} catch (error, StackTrace trace) {
  print(error);
}

StackTrace当前:

-- Aqueduct CLI Version: 3.1.0+1
-- Aqueduct project version: 3.1.0+1
-- Preparing...
-- Starting application 'ntmsapi/ntmsapi'
    Channel: NtmsapiChannel
    Config: /home/capital/.urcs/ntms/ntmsapi/config.yaml
    Port: 8888
[INFO] aqueduct: Server aqueduct/1 started.  
[INFO] aqueduct: Server aqueduct/2 started.  

=====================================================================
RangeError (length): Invalid value: Not in range 0..576460752303423487, inclusive: -197
=====================================================================
=====================================================================
#0      new _List (dart:core/runtime/libarray.dart)
#1      List._allocateData (dart:core/runtime/libgrowable_array.dart:240:16)
#2      List._shrink (dart:core/runtime/libgrowable_array.dart:263:19)
#3      List.length= (dart:core/runtime/libgrowable_array.dart:132:7)
#4      pkcs7Unpad (package:tripledes/src/utils.dart:68:8)
#5      BaseEngine.process (package:tripledes/src/engine.dart:77:7)
#6      BlockCipher.decodeB64 (package:tripledes/tripledes.dart:37:20)
#7      getPrivate (package:ntmsapi/util/ntmsGetPrivate.dart:8:29)
<asynchronous suspension>
#8      NtmsApiController.handle (package:ntmsapi/controller/ntmsapi_controller.dart:36:31)
<asynchronous suspension>
#9      Controller.receive (package:aqueduct/src/http/controller.dart:174:30)
<asynchronous suspension>
#10     Controller.receive (package:aqueduct/src/http/controller.dart:206:28)
<asynchronous suspension>
#11     Router.receive (package:aqueduct/src/http/router.dart:139:18)
<asynchronous suspension>
#12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#14     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#15     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:132:11)
#16     _MapStream._handleData (dart:async/stream_pipe.dart:232:10)
#17     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:164:13)
#18     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#19     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#20     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#21     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#22     _StreamController._add (dart:async/stream_controller.dart:639:7)
#23     _StreamController.add (dart:async/stream_controller.dart:585:5)
#24     _HttpServer._handleRequest (dart:_http/http_impl.dart:2660:19)
#25     new _HttpConnection.<anonymous closure> (dart:_http/http_impl.dart:2418:19)
#26     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#27     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#28     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#29     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#30     _StreamController._add (dart:async/stream_controller.dart:639:7)
#31     _StreamController.add (dart:async/stream_controller.dart:585:5)
#32     _HttpParser._headersEnd (dart:_http/http_parser.dart:372:19)
#33     _HttpParser._doParse (dart:_http/http_parser.dart:701:15)
#34     _HttpParser._parse (dart:_http/http_parser.dart:318:7)
#35     _HttpParser._onData (dart:_http/http_parser.dart:810:5)
#36     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#37     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#38     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#39     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#40     _StreamController._add (dart:async/stream_controller.dart:639:7)
#41     _StreamController.add (dart:async/stream_controller.dart:585:5)
#42     _Socket._onData (dart:io/runtime/binsocket_patch.dart:1721:41)
#43     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#44     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#45     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#46     _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#47     _StreamController._add (dart:async/stream_controller.dart:639:7)
#48     _StreamController.add (dart:async/stream_controller.dart:585:5)
#49     new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1283:33)
#50     _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:826:14)
#51     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#52     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#53     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#54     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

=====================================================================

0 个答案:

没有答案