]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/exception/ServiceNotFoundException.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / exception / ServiceNotFoundException.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.exception;\r
13 \r
14 import org.simantics.db.ServiceLocator;\r
15 \r
16 /**\r
17  * Thrown by {@link ServiceLocator} when requested services are unavailable.\r
18  * \r
19  * @author Tuukka Lehtonen\r
20  */\r
21 public class ServiceNotFoundException extends RuntimeDatabaseException {\r
22 \r
23     private static final long    serialVersionUID = 2454410258587204157L;\r
24 \r
25     private final ServiceLocator locator;\r
26     private final Class<?>       clazz;\r
27 \r
28     public ServiceNotFoundException(ServiceLocator locator, Class<?> clazz, String message) {\r
29         super(message);\r
30         this.locator = locator;\r
31         this.clazz = clazz;\r
32     }\r
33 \r
34     public ServiceNotFoundException(ServiceLocator locator, Class<?> clazz) {\r
35         this.locator = locator;\r
36         this.clazz = clazz;\r
37     }\r
38 \r
39     @Override\r
40     public String toString() {\r
41         StringBuilder sb = new StringBuilder();\r
42         sb.append(clazz.getName()).append(" is not available in ").append(locator.toString());\r
43         String msg = getMessage();\r
44         if (msg != null)\r
45             sb.append(" - ").append(msg);\r
46         return sb.toString();\r
47     }\r
48 \r
49 }\r