replacing textoutputstream.writerror

Is there a basic set of code for handling this depreciation?
I am supposed to use ExceptionHandling.
I am fine with that, but I can’t find the list of errors for this.

Just a tip: you aren’t required to update your code to API 2.0 if now is not the time

For this, you’d catch an IOException.

try
  var tos as TextOutputStream

  // TextOutputStream stuff

  tos.close

catch e as IOException
  // WriteError occurred, check e.Message for details

end try

I know I don’t have to. It’s just annoying I can’t find a table.
If I look up “IOException” I get textoutputstream, but nothing looks like a link to a table.
If you can give a few clues, I’ll be happy to write a request.

AFAICT there isnt one that lists all the exceptions a class might raise

<https://xojo.com/issue/57720>

If Xojo used something like checked exceptions then you’d know what they are from the method declarations themselves
Or an alternative that still let you know from method signatures which exceptions might be raised

Otherwise I can see folks just writing something like

try
  var tos as TextOutputStream

  // TextOutputStream stuff

  tos.close

catch exc as RunttimeException
  // WriteError occurred, check exc.Message for details

end try

because its not well known what exceptions you MIGHT get so you just catch everything just because

Other languages have already gone through this

Thanks. Iostream and RunttimeException should work.

Norman’s comment was made because you should not capture RuntimeException. His illustration was to show how someone might write really bad code.

my bad I should have put a big bold PLEASE DO NOT DO THIS!!! at the top of that code :slight_smile:

its tempting but OMG the awful code that results will hurt down the road

Java went through this ages ago when folks got tired of writing long “throws lists” as part of their method declarations so they just ate every exception and threw nothing
and then code would just NOT work right and it was impossible to tell why

There is a middle ground in between all checked exceptions and none though
But it would require a big refactoring on Xojo’s part

Aah. Subtle humor. I see it now.