diff --git a/b0esche_cloud/lib/pages/file_explorer.dart b/b0esche_cloud/lib/pages/file_explorer.dart index 63549ca..9d965d5 100644 --- a/b0esche_cloud/lib/pages/file_explorer.dart +++ b/b0esche_cloud/lib/pages/file_explorer.dart @@ -1,3 +1,4 @@ +import 'package:dio/dio.dart'; import 'dart:ui'; import 'dart:js_interop'; import 'package:flutter/material.dart'; @@ -314,10 +315,13 @@ class _FileExplorerState extends State { ), ); + final fileService = getIt(); + // If orgId is 'personal', treat as empty string for personal workspace + // Always treat 'personal' or empty orgId as personal workspace + final effectiveOrgId = (widget.orgId == 'personal' || widget.orgId.isEmpty) + ? '' + : widget.orgId; try { - final fileService = getIt(); - // If orgId is 'personal', treat as empty string for personal workspace - final effectiveOrgId = (widget.orgId == 'personal') ? '' : widget.orgId; final fileId = await fileService.createDocument( effectiveOrgId, currentPath, @@ -337,6 +341,16 @@ class _FileExplorerState extends State { } } catch (e) { snackController.close(); + String errorMsg = e.toString(); + // If DioError, try to extract backend error message + if (e is DioError) { + final data = e.response?.data; + if (data is Map && data.containsKey('message')) { + errorMsg = data['message'].toString(); + } else if (data is String) { + errorMsg = data; + } + } if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -346,7 +360,7 @@ class _FileExplorerState extends State { const SizedBox(width: 12), Expanded( child: Text( - 'Failed to create document: $e', + 'Failed to create document: $errorMsg', overflow: TextOverflow.ellipsis, style: const TextStyle(color: AppTheme.primaryText), ),