package io.scalecube.services.examples.exceptions;

import io.scalecube.services.api.ErrorData;
import io.scalecube.services.api.ServiceMessage;
import io.scalecube.services.exceptions.DefaultErrorMapper;
import io.scalecube.services.exceptions.ServiceClientErrorMapper;
import reactor.core.Exceptions;

public class ServiceAClientErrorMapper implements ServiceClientErrorMapper {

  @Override
  public Throwable toError(ServiceMessage message) {
    ErrorData data = message.data();

    if (data.getErrorCode() == 42) {
      // implement service mapping logic
      throw Exceptions.propagate(new ServiceAException(data.getErrorMessage()));
    } else {
      // or delegate it to default mapper
      throw Exceptions.propagate(DefaultErrorMapper.INSTANCE.toError(message));
    }
  }
}

@@ -267,40 +267,8 @@
 per;
-%0Aimport reactor.core.Exceptions;
 %0A%0Apu
@@ -534,35 +534,15 @@
     
-throw Exceptions.propagate(
+return 
 new 
@@ -582,17 +582,16 @@
 ssage())
-)
 ;%0A    %7D 
@@ -649,35 +649,15 @@
     
-throw Exceptions.propagate(
+return 
 Defa
@@ -696,17 +696,16 @@
 message)
-)
 ;%0A    %7D%0A

Fix error mapping example