Giter Site home page Giter Site logo

Comments (8)

lipnikov avatar lipnikov commented on June 10, 2024

Since it is ATS and not Amanzi, more details would be helpful. For example, this exception could be handled inside ATS's main().

from amanzi.

ecoon avatar ecoon commented on June 10, 2024

It's not an ATS thing though since any physics can call get_set_*() calls. I thought it was handled in the geometric model, but apparently not. I can deal with it, but any opposition to putting it there?

from amanzi.

lipnikov avatar lipnikov commented on June 10, 2024

valid_set_name() does the job you need. Of coarse, we can check name validity every time we call get_set_*() and replace one exception with another. But this will be the fourth level of control in Amanzi on the top of (1) Akuna that creates an input file using existing regions, (2) converter that performs many checks and (3) InputAnalysis that verifies mesh sets.

from amanzi.

ecoon avatar ecoon commented on June 10, 2024

No, this is clearly an ask forgiveness not permission. "try" has no overhead on almost all compilers, only costs more if exceptions are thrown, at which point the code is dying anyway so who cares about a bit of overhead.

from amanzi.

lipnikov avatar lipnikov commented on June 10, 2024

Where should we draw a line? Check validity regions of input parameters (like RCP pointers) in all subroutines and throw an exception when checks fail? I vote for using valid_set_name() and improving error messages in this subroutine. But this is Rao's code and I'll follow his advice.

from amanzi.

raovgarimella avatar raovgarimella commented on June 10, 2024

If you use valid_set_name, then you will get a more meaningful error message. It is obviously a non-zero expense so perhaps one can enclose it within a #ifdef DEBUG statement or call AMANZI_ASSERT on its result?

from amanzi.

ecoon avatar ecoon commented on June 10, 2024

Alternately we can try, catch the exception, then call valid_set_name().
Cost is free when the set is valid, and we still get the more useful error
message.

In terms of where to draw the line, I believe that error messages should be
handled in the library/component which has the error. Validating the input
spec is great, but not robust, and not self-contained.

For instance, if the mesh class gets pulled out as a library, calling it
maybe Jolly or something, then the input spec parser is worthless and the
error message is again useless. Components should be as self contained as
possible.

Furthermore, your example isn't a good one -- a bad Ptr/RCP is a developer
bug. A bad set name is a user bug. We should be much more careful about
error messages with regards to the latter.

Ethan

On Fri, Oct 21, 2016 at 1:43 PM Rao Garimella [email protected]
wrote:

If you use valid_set_name, then you will get a more meaningful error
message. It is obviously a non-zero expense so perhaps one can enclose it
within a #ifdef DEBUG statement or call AMANZI_ASSERT on its result?


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#47 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AE43-2w0GABCLURKYYVv-NiRUjoHX08Rks5q2RXSgaJpZM4Kcf0_
.

from amanzi.

ecoon avatar ecoon commented on June 10, 2024

from amanzi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.