Class DiagnosticErrorBuilder


  • public class DiagnosticErrorBuilder
    extends Object
    Utility class for building DiagnosticError instances.
    Author:
    Joe Lauer (https://twitter.com/jjlauer), Fizzed, Inc. (http://fizzed.com)
    • Constructor Detail

      • DiagnosticErrorBuilder

        public DiagnosticErrorBuilder()
    • 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)
      • 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.