Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to read header results in writing to stderr #41

Open
effigies opened this issue Aug 12, 2024 · 2 comments
Open

Failure to read header results in writing to stderr #41

effigies opened this issue Aug 12, 2024 · 2 comments

Comments

@effigies
Copy link

} else {
console.error("That file does not appear to be NIFTI!");
}

It's not ideal to have console.error obligatorily called by a library, as it pollutes my output. I'm going to handle a null return value myself. Would it be possible to either remove the call or make it possible to turn off?

In the short term, I'm just wrapping:

function readHeaderQuiet(buf: ArrayBuffer) {
  const console_error = console.error
  console.error = () => {}
  const header = readHeader(buf)
  console.error = console_error
  return header
}
@hanayik
Copy link
Collaborator

hanayik commented Aug 12, 2024

@effigies, would you prefer throw new Error('That file does not appear to be NIFTI!')? I think it is definitely helpful to tell the user something doesn't look correct. I have personally found this useful in Niivue.

@effigies
Copy link
Author

I'm perfectly happy with null, but I can catch an error, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants