Package ninja.diagnostics
Class DiagnosticErrorBuilder
- java.lang.Object
-
- ninja.diagnostics.DiagnosticErrorBuilder
-
public class DiagnosticErrorBuilder extends Object
Utility class for buildingDiagnosticErrorinstances.- Author:
- Joe Lauer (https://twitter.com/jjlauer), Fizzed, Inc. (http://fizzed.com)
-
-
Constructor Summary
Constructors Constructor Description DiagnosticErrorBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DiagnosticErrorbuild400BadRequestDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode)static DiagnosticErrorbuild401UnauthorizedDiagnosticError()static DiagnosticErrorbuild403ForbiddenDiagnosticError()static DiagnosticErrorbuild403ForbiddenDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode)static DiagnosticErrorbuild404NotFoundDiagnosticError(boolean tryToReadLinesFromSourceCode)static DiagnosticErrorbuild404NotFoundDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode)static DiagnosticErrorbuild500InternalServerErrorDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode, Result underlyingResult)static DiagnosticErrorbuildDiagnosticError(String title, Throwable throwable, boolean tryToReadLinesFromSourceCode, Result underlyingResult)static DiagnosticErrorbuildDiagnosticError(String title, Throwable throwable, String relativeSourcePath, int lineNumberOfError, Result underlyingResult)static DiagnosticErrorbuildDiagnosticError(String title, Throwable throwable, String packageName, String fileName, int lineNumberOfError, Result underlyingResult)static DiagnosticErrorbuildDiagnosticError(String title, Throwable throwable, SourceSnippet snippet, int lineNumberOfError, Result underlyingResult)static StackTraceElementfindFirstStackTraceElementWithSourceCodeInProject(Throwable throwable)static StringgetSourceCodeRelativePathForStackTraceElement(StackTraceElement ste)Calculates the relative path of the source code file of a StackTrace element if its available.static booleansourceCodeExistsInProject(String sourceRelativePath)static SourceSnippettryToReadSourceSnippet(String sourceRelativePath, int lineFrom, int lineTo)static SourceSnippettryToReadSourceSnippetInPackage(String packageName, String fileName, int lineFrom, int lineTo)
-
-
-
Method Detail
-
build404NotFoundDiagnosticError
public static DiagnosticError build404NotFoundDiagnosticError(boolean tryToReadLinesFromSourceCode)
-
build404NotFoundDiagnosticError
public static DiagnosticError build404NotFoundDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode)
-
build403ForbiddenDiagnosticError
public static DiagnosticError build403ForbiddenDiagnosticError()
-
build403ForbiddenDiagnosticError
public static DiagnosticError build403ForbiddenDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode)
-
build401UnauthorizedDiagnosticError
public static DiagnosticError build401UnauthorizedDiagnosticError()
-
build500InternalServerErrorDiagnosticError
public static DiagnosticError build500InternalServerErrorDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode, Result underlyingResult)
-
build400BadRequestDiagnosticError
public static DiagnosticError build400BadRequestDiagnosticError(Throwable cause, boolean tryToReadLinesFromSourceCode)
-
buildDiagnosticError
public static DiagnosticError buildDiagnosticError(String title, Throwable throwable, boolean tryToReadLinesFromSourceCode, Result underlyingResult)
-
buildDiagnosticError
public static DiagnosticError buildDiagnosticError(String title, Throwable throwable, String packageName, String fileName, int lineNumberOfError, Result underlyingResult)
-
buildDiagnosticError
public static DiagnosticError buildDiagnosticError(String title, Throwable throwable, String relativeSourcePath, int lineNumberOfError, Result underlyingResult)
-
buildDiagnosticError
public static DiagnosticError buildDiagnosticError(String title, Throwable throwable, SourceSnippet snippet, int lineNumberOfError, Result underlyingResult)
-
findFirstStackTraceElementWithSourceCodeInProject
public static StackTraceElement findFirstStackTraceElementWithSourceCodeInProject(Throwable throwable)
-
sourceCodeExistsInProject
public static boolean sourceCodeExistsInProject(String sourceRelativePath)
-
tryToReadSourceSnippetInPackage
public static SourceSnippet tryToReadSourceSnippetInPackage(String packageName, String fileName, int lineFrom, int lineTo)
-
tryToReadSourceSnippet
public static SourceSnippet tryToReadSourceSnippet(String sourceRelativePath, int lineFrom, int lineTo)
-
getSourceCodeRelativePathForStackTraceElement
public static String getSourceCodeRelativePathForStackTraceElement(StackTraceElement ste)
Calculates the relative path of the source code file of a StackTrace element if its available. Uses the packageName of the class to create a relative path and appends the "filename" included with the stack trace element.- Parameters:
ste- The stack trace element- Returns:
- The relative path of the source code file or null if the information wasn't available in the stack trace element.
-
-