All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.scalecube.services.examples.exceptions.ServiceAProviderErrorMapper Maven / Gradle / Ivy

package io.scalecube.services.examples.exceptions;

import io.scalecube.services.api.ServiceMessage;
import io.scalecube.services.exceptions.BadRequestException;
import io.scalecube.services.exceptions.DefaultErrorMapper;
import io.scalecube.services.exceptions.ServiceProviderErrorMapper;

public class ServiceAProviderErrorMapper implements ServiceProviderErrorMapper {

  @Override
  public ServiceMessage toMessage(Throwable throwable) {
    // implement service mapping logic
    if (throwable instanceof ServiceAException) {
      ServiceAException e = (ServiceAException) throwable;
      return ServiceMessage.error(BadRequestException.ERROR_TYPE, e.code(), e.getMessage());
    }

    // or delegate it to default mapper
    return DefaultErrorMapper.INSTANCE.toMessage(throwable);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy