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

Better error messager for read/write mesh #21

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/gpytoolbox/read_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ def _read_obj(file,return_UV,return_N,reader):
if reader=="C++":
err,V,F,UV,Ft,N,Fn = _read_obj_cpp_impl(file,return_UV,return_N)
if err != 0:
raise Exception(f"Error {err} reading obj file.")
if err == -5:
raise Exception(f"The file {file} could not be opened.")
elif err == -7:
raise Exception(f"A line in {file} was ill-formed.")
elif err == -8:
raise Exception(f"{file} does not seem to be a triangle mesh.")
else:
raise Exception(f"Unknown error {err} reading obj file.")
elif reader=="Python":
V,F,UV,Ft,N,Fn = _read_obj_python(file,return_UV,return_N)
else:
Expand Down
9 changes: 8 additions & 1 deletion src/gpytoolbox/write_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ def _write_obj(file,V,F,UV,Ft,N,Fn,writer):
N.astype(np.float64),
Fn.astype(np.int32))
if err != 0:
raise Exception(f"Error {err} writing obj file.")
if err == -11:
raise Exception("Ft has the wrong dimensions.")
elif err == -12:
raise Exception("Fn has the wrong dimensions.")
elif err == -5:
raise Exception(f"The file {file} could not be opened.")
else:
raise Exception(f"Unknown error {err} writing obj file.")
elif writer=="Python":
_write_obj_python(file,V,F,UV,Ft,N,Fn)
else:
Expand Down