error.dart 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:appflowy_backend/protobuf/dart-ffi/protobuf.dart';
  2. class FlowyInternalError {
  3. late FFIStatusCode _statusCode;
  4. late String _error;
  5. FFIStatusCode get statusCode {
  6. return _statusCode;
  7. }
  8. String get error {
  9. return _error;
  10. }
  11. bool get has_error {
  12. return _statusCode != FFIStatusCode.Ok;
  13. }
  14. String toString() {
  15. return "$_statusCode: $_error";
  16. }
  17. FlowyInternalError(
  18. {required FFIStatusCode statusCode, required String error}) {
  19. _statusCode = statusCode;
  20. _error = error;
  21. }
  22. factory FlowyInternalError.from(FFIResponse resp) {
  23. return FlowyInternalError(statusCode: resp.code, error: "");
  24. }
  25. }
  26. class StackTraceError {
  27. Object error;
  28. StackTrace trace;
  29. StackTraceError(
  30. this.error,
  31. this.trace,
  32. );
  33. FlowyInternalError asFlowyError() {
  34. return FlowyInternalError(
  35. statusCode: FFIStatusCode.Err, error: this.toString());
  36. }
  37. String toString() {
  38. return '${error.runtimeType}. Stack trace: $trace';
  39. }
  40. }