-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 44 additions & 9 deletions
53
routerlib/src/main/java/com/lzh/nonview/router/exception/NotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,66 @@ | ||
/* | ||
* Copyright (C) HaoGe <a href="https://github.com/yjfnypeu"/> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.lzh.nonview.router.exception; | ||
|
||
/** | ||
* The custom exception represents not found | ||
* @author haoge | ||
* @see NotFoundType | ||
*/ | ||
public class NotFoundException extends RuntimeException { | ||
|
||
private final NotFoundType type; | ||
/** | ||
* This type represents not matching to the corresponding uri routing rules | ||
*/ | ||
public static final int TYPE_SCHEMA = 0; | ||
/** | ||
* This type represents the uri matching to the routing target does not exist | ||
*/ | ||
public static final int TYPE_CLZ = 1; | ||
|
||
private final int type; | ||
private final String notFoundName; | ||
|
||
public NotFoundException(String detailMessage, NotFoundType type,String notFoundName) { | ||
/** | ||
* @param detailMessage detail error message | ||
* @param type one of {@link NotFoundException#TYPE_SCHEMA} and {@link NotFoundException#TYPE_SCHEMA} | ||
* @param notFoundName The routing target name matched with uri. | ||
* @see NotFoundException#TYPE_SCHEMA | ||
* @see NotFoundException#TYPE_CLZ | ||
*/ | ||
public NotFoundException(String detailMessage, int type,String notFoundName) { | ||
super(detailMessage); | ||
this.type = type; | ||
this.notFoundName = notFoundName; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public NotFoundType getType() { | ||
/** | ||
* @return the type of not found. it could be one of the {@link NotFoundException#TYPE_SCHEMA} and {@link NotFoundException#TYPE_SCHEMA} | ||
* @see NotFoundException#TYPE_SCHEMA | ||
* @see NotFoundException#TYPE_CLZ | ||
*/ | ||
public int getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* @return the uri matching routing target class name. | ||
*/ | ||
public String getNotFoundName() { | ||
return notFoundName; | ||
} | ||
|
||
public enum NotFoundType { | ||
CLZ, | ||
SCHEME, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters