Merge "Catch callback in network service doesn't throw"

This commit is contained in:
Zuul
2025-10-15 21:40:49 +00:00
committed by Gerrit Code Review
2 changed files with 20 additions and 10 deletions

View File

@@ -59,8 +59,9 @@
*/
function getFloatingIps() {
return apiService.get('/api/network/floatingips/')
.catch(function onError() {
.catch(function onError(response) {
toastService.add('error', gettext('Unable to retrieve floating IPs.'));
throw response;
});
}
@@ -74,8 +75,9 @@
*/
function getFloatingIpPools() {
return apiService.get('/api/network/floatingippools/')
.catch(function onError() {
.catch(function onError(response) {
toastService.add('error', gettext('Unable to retrieve floating IP pools.'));
throw response;
});
}
@@ -91,8 +93,9 @@
*/
function allocateFloatingIp(poolId) {
return apiService.post('/api/network/floatingip/', { pool_id: poolId })
.catch(function onError() {
.catch(function onError(response) {
toastService.add('error', gettext('Unable to allocate new floating IP address.'));
throw response;
});
}
@@ -111,8 +114,9 @@
function associateFloatingIp(addressId, portId) {
var params = { address_id: addressId, port_id: portId };
return apiService.patch('/api/network/floatingip/', params)
.catch(function onError() {
.catch(function onError(response) {
toastService.add('error', gettext('Unable to associate floating IP address.'));
throw response;
});
}
@@ -127,8 +131,9 @@
*/
function disassociateFloatingIp(addressId) {
return apiService.patch('/api/network/floatingip/', { address_id: addressId })
.catch(function onError() {
.catch(function onError(response) {
toastService.add('error', gettext('Unable to disassociate floating IP address.'));
throw response;
});
}

View File

@@ -42,13 +42,15 @@
func: 'getFloatingIps',
method: 'get',
path: '/api/network/floatingips/',
error: 'Unable to retrieve floating IPs.'
error: 'Unable to retrieve floating IPs.',
throws: true
},
{
func: 'getFloatingIpPools',
method: 'get',
path: '/api/network/floatingippools/',
error: 'Unable to retrieve floating IP pools.'
error: 'Unable to retrieve floating IP pools.',
throws: true
},
{
func: 'allocateFloatingIp',
@@ -56,7 +58,8 @@
path: '/api/network/floatingip/',
data: { pool_id: 'pool' },
error: 'Unable to allocate new floating IP address.',
testInput: [ 'pool' ]
testInput: [ 'pool' ],
throws: true
},
{
func: 'associateFloatingIp',
@@ -64,7 +67,8 @@
path: '/api/network/floatingip/',
data: { address_id: 'address', port_id: 'port' },
error: 'Unable to associate floating IP address.',
testInput: [ 'address', 'port' ]
testInput: [ 'address', 'port' ],
throws: true
},
{
func: 'disassociateFloatingIp',
@@ -72,7 +76,8 @@
path: '/api/network/floatingip/',
data: { address_id: 'address' },
error: 'Unable to disassociate floating IP address.',
testInput: [ 'address' ]
testInput: [ 'address' ],
throws: true
}
];