Re: Structured exception information



Maciej Sobczak <no.spam@xxxxxxxxxxx> writes:

Generally, all you can do is report the error to
the user.
That's what I want to do.
Then what's wrong with a string?

Doesn't feel as type-safe as advertised.

But you have not given an actual example where a string is not
a type-safe solution to the actual problem at hand.

The only example you have given is "present the error to the user". In
that case, a string is precisely the correct type.

- error code
- error message
- line number
- character position
- hint from the engine
- timestamp from within the engine
- ...
All of this can be put into the string by the routine raising the
exception:
[...]

Sure. That's why there are more JavaScript programmers than Ada programmers.

I don't follow. Strings are perfectly valid Ada constructs. Why does
the code to build the string not feel like Ada to you?

raise Database_Error with "Error " & Error_Code_Type'image
(Error_Code) & ": " & Time_Type'image (Timestamp) & ": " &
file_name & ":" & Integer'image (Line_Number) &
":" & Integer'image (Character_Position) & ": " & Message &
": " & Hint;

Of course, with similar routine for dismantling all this in the
handler.

You have not said _why_ you need to dismantle this information in the
handler. What, _exactly_, will the handler do with the separate bits?

Still, that's not what I expect from Ada.

Lots of people expect lots of things. Sometimes, those expectations
are unreasonable, and should be changed. That's what I'm trying to
explore here; I think expecting anything other than a string for
exception data is unreasonable.

So far, you have presented no case to show I am wrong.

As a general matter of user-interface design, I would find that
annoying. As a user of a system, the only thing I want from an error
message is either "how do I fix this myself" or "how do I report this
to the maintenance team".

That is a reasonable approach and will work fine most of the time,

When will it not work? I have never encountered such a case.

but it does not explain the lack of a language feature that is taken
for granted in other languages - and coming from another language, I
find the lack of structured exception information as a defect, even
though I realize that I can easily work around it. The point is that
I should not be forced to work around anything.

If you look into the details of "structured exception handling" in
other languages and implementations, they have bugs, and fundamental
flaws in design. That is why Ada did not go that way. Ada is _much_
more careful about getting the core design right, allowing fully
robust and safe implementations of _all_ features, especially in
multi-tasking and multi-processing environments.

So if you find yourself fighting Ada to do something, you need to step
back and think more carefully about _why_ you are doing it that way.
Ada is telling you it is inherently unsafe.

--
-- Stephe
.



Relevant Pages

  • Re: The future of Ada is at risk
    ... working under Mac OS X. ... People should have the opportunity to "give Ada a spin" free of charge, ... I don't see how simple but powerful string handling ... I think that the default string type should be the unbounded string, ...
    (comp.lang.ada)
  • Re: How come Ada isnt more popular?
    ... Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm ... Perhaps if the central string were a number? ... But when I compare a book on expert systems written in C and one written in Ada (well, Ada83), the book in Ada is both thicker and has more pages devoted to code than the book in C, and the expert systems are approximately of equivalent power. ...
    (comp.lang.ada)
  • Re: Teaching new tricks to an old dog (C++ -->Ada)
    ... In Ada I could use Ada.Strings.Bounded_Strings ... not at all convinced that two separate string classes are necessary to ... allocator that only ever allocates a block of the initially-specified ... And thead save means that an exception may be ...
    (comp.lang.ada)
  • Re: Interpretation of extensions different from Unix/Linux?
    ... the use of UTF-8 in this way is the recommendation of the ARG. ... (UTF-8 is a problem of its own in Ada. ... a UTF-8 encoded string is a String. ... You can't enumerate roots in Windows, ...
    (comp.lang.ada)
  • Re: Data table text I/O package?
    ... > And if you don't know what you are analyzing for, Ada is hardly the ... > programming language to be using. ... there isn't a way to search for an unbounded string in another ... > unbounded string. ...
    (comp.lang.ada)