mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 21:18:08 +01:00
Propagate certain subscription processor errors to client responses
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2023 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.mappers;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
import org.whispersystems.textsecuregcm.subscriptions.SubscriptionProcessorException;
|
||||
|
||||
public class SubscriptionProcessorExceptionMapper implements ExceptionMapper<SubscriptionProcessorException> {
|
||||
|
||||
public static final int EXTERNAL_SERVICE_ERROR_STATUS_CODE = 440;
|
||||
|
||||
@Override
|
||||
public Response toResponse(final SubscriptionProcessorException exception) {
|
||||
return Response.status(EXTERNAL_SERVICE_ERROR_STATUS_CODE)
|
||||
.entity(Map.of(
|
||||
"processor", exception.getProcessor().name(),
|
||||
"chargeFailure", exception.getChargeFailure()
|
||||
))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user