Skip to content

Commit

Permalink
Simplify MagickImage.useException(Pointer).
Browse files Browse the repository at this point in the history
  • Loading branch information
Peeterush authored and dlemstra committed Feb 10, 2024
1 parent d2012c8 commit 89d6670
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/magick-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3172,18 +3172,14 @@ export class MagickImage extends NativeInstance implements IMagickImage {
}

private useException<TReturnType>(func: (exception: Exception) => TReturnType): TReturnType {
return Exception.use<TReturnType>(exception => {
return func(exception);
}, (error: MagickError) => {
return Exception.use<TReturnType>(func, error => {
if (this.onWarning !== undefined)
this.onWarning(new WarningEvent(error));
});
}

private useExceptionPointer<TReturnType>(func: (exception: number) => TReturnType): TReturnType {
return Exception.usePointer<TReturnType>(exception => {
return func(exception);
}, (error: MagickError) => {
return Exception.usePointer<TReturnType>(func, error => {
if (this.onWarning !== undefined)
this.onWarning(new WarningEvent(error));
});
Expand Down

0 comments on commit 89d6670

Please sign in to comment.