Skip to content

Commit

Permalink
Inaccurate error message in ui.image when file does not exist (#3162)
Browse files Browse the repository at this point in the history
* fix:add finished event

* fix tailwind classes problem

* code review

* fix pytest

* add check file exists

* move file existence check into SourceElement

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>
  • Loading branch information
CrystalWindSnake and falkoschindler authored Jun 2, 2024
1 parent 92a0cf0 commit 2e00244
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nicegui/elements/mixins/source_element.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from typing import Any, Callable, Optional, cast

from typing_extensions import Self
Expand Down Expand Up @@ -98,6 +99,8 @@ def _set_props(self, source: Any) -> None:
else:
source = core.app.add_static_file(local_file=source)
self.auto_route = source
if isinstance(source, Path) and not source.exists():
raise FileNotFoundError(f'File not found: {source}')
self._props['src'] = source

def _handle_delete(self) -> None:
Expand Down

0 comments on commit 2e00244

Please sign in to comment.