-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[36] Avoid using costly Exception for package not found errors
Bug: #36 Signed-off-by: Pierre-Charles David <[email protected]>
- Loading branch information
1 parent
e13d502
commit d735322
Showing
2 changed files
with
35 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Obeo. | ||
* Copyright (c) 2020, 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
|
@@ -12,22 +12,26 @@ | |
*******************************************************************************/ | ||
package org.eclipse.sirius.emfjson.resource; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.emf.ecore.resource.Resource; | ||
|
||
/** | ||
* This exception is throw when a package is not found. | ||
* | ||
* @author <a href="mailto:[email protected]">Guillaume Coutable</a> | ||
*/ | ||
public class PackageNotFoundException extends JsonException { | ||
public class PackageNotFoundError implements Resource.Diagnostic { | ||
|
||
/** | ||
* . | ||
* The uri that correspond to the missing package. | ||
*/ | ||
private static final long serialVersionUID = 1L; | ||
protected final String uri; | ||
|
||
/** | ||
* The uri that correspond to the missing package. | ||
* The source location of the issue. | ||
*/ | ||
protected final String uri; | ||
private final String location; | ||
|
||
/** | ||
* The constructor. | ||
|
@@ -37,9 +41,29 @@ public class PackageNotFoundException extends JsonException { | |
* @param location | ||
* the location | ||
*/ | ||
public PackageNotFoundException(String uri, String location) { | ||
super("Package with uri '" + uri + "' not found.", location); //$NON-NLS-1$//$NON-NLS-2$ | ||
this.uri = uri; | ||
public PackageNotFoundError(String uri, String location) { | ||
this.uri = Objects.requireNonNull(uri); | ||
this.location = Objects.requireNonNull(location); | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return String.format("Package with uri '%s' not found.", this.uri); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public String getLocation() { | ||
return this.location; | ||
} | ||
|
||
@Override | ||
public int getColumn() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLine() { | ||
return 0; | ||
} | ||
|
||
/** | ||
|
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