Skip to content

[main] [bug] Catch RequestException instead of Throwable in DatabaseDelete#138

Merged
joetannenbaum merged 1 commit intolaravel:mainfrom
JoshSalway:fix/database-delete-catch-request-exception
Apr 10, 2026
Merged

[main] [bug] Catch RequestException instead of Throwable in DatabaseDelete#138
joetannenbaum merged 1 commit intolaravel:mainfrom
JoshSalway:fix/database-delete-catch-request-exception

Conversation

@JoshSalway
Copy link
Copy Markdown
Contributor

@JoshSalway JoshSalway commented Apr 7, 2026

Fixes #46

Summary

DatabaseDelete catches Throwable instead of RequestException. This catches everything including TypeError, OutOfMemoryError, and other non-API errors, masking real bugs as "Failed to delete database" messages. All other delete commands catch RequestException.

Proof

BEFORE: catch(Throwable) - current code
  API error (RequestException): CAUGHT - shown as 'Failed to delete database'
  Type bug (TypeError): CAUGHT - shown as 'Failed to delete database'
  Memory crash (Error): CAUGHT - shown as 'Failed to delete database'
  Bad method call: CAUGHT - shown as 'Failed to delete database'

AFTER: catch(RequestException) - this PR
  API error (RequestException): CAUGHT - friendly API error message
  Type bug (TypeError): NOT CAUGHT - propagates correctly as TypeError
  Memory crash (Error): NOT CAUGHT - propagates correctly as Error
  Bad method call: NOT CAUGHT - propagates correctly as BadMethodCallException

Before / After

// Before - catches everything, masks real bugs:
use Throwable;

} catch (Throwable $e) {
    error('Failed to delete database: '.$e->getMessage());
}

// After - only catches API errors, consistent with other delete commands:
use Saloon\Exceptions\Request\RequestException;

} catch (RequestException $e) {
    error('Failed to delete database: '.$e->getMessage());
}

Consistency

Every other delete command already catches RequestException:

  • ApplicationDelete
  • BackgroundProcessDelete
  • DatabaseClusterDelete
  • DomainDelete
  • EnvironmentDelete
  • InstanceDelete

DatabaseDelete was the only outlier.

Throwable catches everything including TypeError, OutOfMemoryError,
etc. masking real bugs as API errors. All other delete commands
catch RequestException. This makes DatabaseDelete consistent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@joetannenbaum joetannenbaum merged commit a1db53b into laravel:main Apr 10, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

Bug: DatabaseDelete catches Throwable, swallows CommandExitException

2 participants