Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:54:37+00:00 2026-06-14T09:54:37+00:00

My understanding is it is better practice to test beforehand to avoid exceptions, rather

  • 0

My understanding is it is better practice to test beforehand to avoid exceptions, rather than catching them. Is there any way to check if an asset file exists before attempting to open it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:54:39+00:00Added an answer on June 14, 2026 at 9:54 am

    There is no such feature available to assets, however, there is no need for it (see below).

    My understanding is it is better practice to test beforehand to avoid exceptions, rather than catching them.

    This is only true if an exception is a part of the normal (expected) operation of your application. In other words, if an exception is a statistically common event (e.g. you expect it to happen “often” at a certain place), then catching it may have significant performance costs. (In practice, this matters only in case of many exceptions caught in a short period of time, so benchmarking is always important.)

    Since you usually don’t expect an asset to be missing when trying to access it (otherwise something is wrongly designed in your application), it is fine to use an exception handler for exceptional cases.

    To sum up, error handling with exceptions has performance costs, but errors (especially errors to be suppressed) are expected to be rare events. If you expect errors to happen very often in a certain part of your application, then something may be wrong in your design. (Some very exceptional situations are possible where this is not true, but these are very rare and atypical application domains.)

    In practice: in your case, e.g. it is OK to use exceptions if the asset name comes from external (e.g. user) input. This is because the “frequency” of possible exceptions is low. On the other hand, if you are trying to decide for many assets if each of them exists (e.g. in a loop), then exception handling might have unacceptable performance costs — but I can hardly imagine that such a thing would be needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a better understanding than I've been able to so far...it's
I'm having a hard time understanding why there is only one test per function
I'm trying to get a better understanding of general practice... specifically deriving this() in
Q: Is there any way to implement self-documenting enumerations in standard SQL? EXAMPLE: Column:
For a better understanding of my question, see the following classes: public interface Invoker<R>
I'd like to get a better understanding of the isAssignableFrom behaviour in Java between
I'm writing a simple calendar control for better understanding of WPF. I have a
I'm playing with DLR to get a better understanding of it. I'm not completely
I have two basic interface-related concepts that I need to have a better understanding
I'm fairly new to Rails and I'm trying to gain a better understanding of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.