cadius icon indicating copy to clipboard operation
cadius copied to clipboard

Return some error codes

Open sicklittlemonkey opened this issue 7 years ago • 7 comments

A starter for #20.

I've only tested ADDFILE.

sicklittlemonkey avatar Apr 10 '18 10:04 sicklittlemonkey

Awesome! This was super annoying while using in build scripts that should fail early but no way to tell.

mach-kernel avatar Apr 11 '18 14:04 mach-kernel

The other code paths all have good error-handling code, but don't return int.

It should be easy to change.

sicklittlemonkey avatar Apr 11 '18 19:04 sicklittlemonkey

Ok, I did EXTRACTFILE in 5 minutes - but not tested! ; - )

Look at the existing error handling in AddFile.

If there's an error:

  • Update the current image, i.e. current_image->nb_add_error++ or nb_extract_error++;
  • Free memory if it won't be used again (e.g. you're returning now) e.g. mem_free_file(current_file);
  • In general return(1), though if there's an error variable it's better to return(error); IMO.

The other ones get a bit more involved because there are loops etc. (Damn I wish this was in C++.)

I'll try to do a more complex one later and see how hard it gets.

Cheers, Nick.

sicklittlemonkey avatar Apr 11 '18 20:04 sicklittlemonkey

I'll do some testing this evening 👍

(Damn I wish this was in C++.)

I was playing around with the idea of using Go with Cgo to write a niftier CLI tool while using all of the existing ProDOS code as a library.

mach-kernel avatar Apr 11 '18 20:04 mach-kernel

Ok, I have no idea what's going in my fork anymore. No time for this nonsense. ; - )

sicklittlemonkey avatar Apr 24 '18 10:04 sicklittlemonkey

Oh, what happened to this one? Sorry, Git was pissing me off and I haven't had time to get back to it.

sicklittlemonkey avatar Jan 03 '20 03:01 sicklittlemonkey

Hi there! I reopened it, thought it was abandoned because of the merge conflicts. I think this feature is necessary if people want to use this in any kind of script. Do we want to just do 0/1 or come up with more granular code semantics? I'm happy to help rebase + do stuff for this branch if you would welcome that! 😸

mach-kernel avatar Jan 03 '20 19:01 mach-kernel