flowy_error.dart 729 B

1234567891011121314151617181920212223242526272829303132333435
  1. import '../protobuf/ffi_response.pb.dart';
  2. class FlowyError {
  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. FlowyError({required FFIStatusCode statusCode, required String error}) {
  18. _statusCode = statusCode;
  19. _error = error;
  20. }
  21. factory FlowyError.from(FFIResponse resp) {
  22. return FlowyError(statusCode: resp.code, error: resp.error);
  23. }
  24. factory FlowyError.fromError(String error) {
  25. return FlowyError(statusCode: FFIStatusCode.Err, error: error);
  26. }
  27. }