1010import io .eigr .spawn .api .actors .annotations .stateless .StatelessNamedActor ;
1111import io .eigr .spawn .api .actors .annotations .stateless .StatelessPooledActor ;
1212import io .eigr .spawn .api .actors .annotations .stateless .StatelessUnNamedActor ;
13+ import io .eigr .spawn .api .exceptions .ActorCreationException ;
14+ import io .eigr .spawn .api .exceptions .ActorRegistrationException ;
15+ import io .eigr .spawn .api .exceptions .SpawnException ;
1316import io .eigr .spawn .internal .Entity ;
1417import io .eigr .spawn .internal .transport .client .OkHttpSpawnClient ;
1518import io .eigr .spawn .internal .transport .client .SpawnClient ;
@@ -75,9 +78,10 @@ public String getSystem() {
7578 * @param system ActorSystem name of the actor that this ActorRef instance should represent
7679 * @param name the name of the actor that this ActorRef instance should represent
7780 * @return the ActorRef instance
81+ * @throws {@link io.eigr.spawn.api.exceptions.ActorCreationException}
7882 * @since 0.0.1
7983 */
80- public ActorRef createActorRef (String system , String name ) throws Exception {
84+ public ActorRef createActorRef (String system , String name ) throws ActorCreationException {
8185 return ActorRef .of (this .client , system , name );
8286 }
8387
@@ -89,9 +93,10 @@ public ActorRef createActorRef(String system, String name) throws Exception {
8993 * @param name the name of the actor that this ActorRef instance should represent
9094 * @param parent the name of the unnamed parent actor
9195 * @return the ActorRef instance
96+ * @throws {@link io.eigr.spawn.api.exceptions.ActorCreationException}
9297 * @since 0.0.1
9398 */
94- public ActorRef createActorRef (String system , String name , String parent ) throws Exception {
99+ public ActorRef createActorRef (String system , String name , String parent ) throws ActorCreationException {
95100 return ActorRef .of (this .client , system , name , parent );
96101 }
97102
@@ -105,14 +110,18 @@ public void start() throws Exception {
105110 registerActorSystem ();
106111 }
107112
108- private void startServer () throws IOException {
109- HttpServer httpServer = HttpServer .create (new InetSocketAddress (this .host , this .port ), 0 );
110- httpServer .createContext (HTTP_ACTORS_ACTIONS_URI , new ActorServiceHandler (this , this .entities ));
111- httpServer .setExecutor (this .executor );
112- httpServer .start ();
113+ private void startServer () throws SpawnException {
114+ try {
115+ HttpServer httpServer = HttpServer .create (new InetSocketAddress (this .host , this .port ), 0 );
116+ httpServer .createContext (HTTP_ACTORS_ACTIONS_URI , new ActorServiceHandler (this , this .entities ));
117+ httpServer .setExecutor (this .executor );
118+ httpServer .start ();
119+ }catch (IOException ex ) {
120+ throw new SpawnException (ex );
121+ }
113122 }
114123
115- private void registerActorSystem () throws Exception {
124+ private void registerActorSystem () throws ActorRegistrationException {
116125 ActorOuterClass .Registry registry = ActorOuterClass .Registry .newBuilder ()
117126 .putAllActors (getActors (this .entities ))
118127 .build ();
0 commit comments