Skip to content

Commit

Permalink
Fix #681: Replace unfriendly error message for non-ROM files
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Dec 23, 2023
1 parent d9b4f88 commit 6fd3124
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion skytemple/core/rom_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
import os
import shutil
import struct
import sys
from enum import Enum, auto
from typing import (
Expand All @@ -40,7 +41,7 @@
from gi.repository import GLib, Gtk
from ndspy.rom import NintendoDSRom
from pmdsky_debug_py.protocol import SectionProtocol
from skytemple_files.user_error import mark_as_user_err
from skytemple_files.user_error import mark_as_user_err, UserValueError

from skytemple.core.item_tree import ItemTreeEntryRef
from skytemple.core.profiling import record_transaction, record_span, TaggableContext
Expand Down Expand Up @@ -233,6 +234,14 @@ async def load(self, transaction: Optional[TaggableContext] = None):
except OSError as e:
mark_as_user_err(e)
raise e
except struct.error:
raise UserValueError(
_("There was an error trying to read the ROM file.")
+ " "
+ _(
'Are you sure you provided a ROM? A ROM usually has the file extension ".nds".'
)
)
await AsyncTaskDelegator.buffer()
self._loaded_modules = {}

Expand Down

0 comments on commit 6fd3124

Please sign in to comment.