Standardize throwing of warnings and errors in library functions