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

Update GetImageBlob/GetImagesBlob to return error as second element #321

Merged
merged 3 commits into from
Jun 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions imagick/magick_wand_exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@ func (mw *MagickWand) clearException() bool {
return 1 == C.int(C.MagickClearException(mw.mw))
}

// Returns the kind, reason and description of any error that occurs when using other methods in this API
// GetLastError returns the kind, reason and description of any error that occurs when using other methods in this API.
// The exception is cleared after this call.
func (mw *MagickWand) GetLastError() error {
return mw.getLastError(true)
}

// Returns the kind, reason and description of any error that occurs when using other methods in this API.
// Clears the exception, if clear is true.
func (mw *MagickWand) getLastError(clear bool) error {
var et C.ExceptionType
csdescription := C.MagickGetException(mw.mw, &et)
defer relinquishMemory(unsafe.Pointer(csdescription))
if ExceptionType(et) != EXCEPTION_UNDEFINED {
mw.clearException()
if clear {
mw.clearException()
}
return &MagickWandException{ExceptionType(C.int(et)), C.GoString(csdescription)}
}
runtime.KeepAlive(mw)
Expand Down
Loading
Loading