Web Connection
Error management in REST service
Gravatar is a globally recognized avatar based on your email address. Error management in REST service
  Michele
  All
  Jun 28, 2024 @ 05:07am

I have seen that when the REST service encounters an error, it still responds with an html page within which, among other things, the error message is also found. What I was asking is if it is possible to intervene on the formatting of this answer. If it is possible to modify the graphics of this page or eliminate it completely and reply with a simple text containing only the part relating to the error. Thank you

Gravatar is a globally recognized avatar based on your email address. re: Error management in REST service
  Rick Strahl
  Michele
  Jun 28, 2024 @ 07:45am

No that's not the way it works if you're using a wwProcess class unless the error occurs in the actual IIS layer (ie. a hard 404 for a static resource). Anything that is routed through to the REST service and that actually hits the REST service pipeline will produce a JSON error message. IOW any request to the script map will produce a JSON response if you're using a wwRestProcess subclass.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Error management in REST service
  Michele
  Rick Strahl
  Jun 30, 2024 @ 11:13pm

When i have an error in my function i receive this HTML as response

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Com Server Execution Error</title>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="" />

    <link rel="shortcut icon" href="http://localhost/restconnect/favicon.ico" type="image/x-icon" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <link rel="apple-touch-icon" href="http://localhost/restconnect/touch-icon.png" />

    <link rel="icon" href="http://localhost/restconnect/touch-icon.png" />
    <meta name="msapplication-TileImage" content="http://localhost/restconnect/touch-icon.png">

    <link href="http://localhost/restconnect/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
    <link href="http://localhost/restconnect/lib/fontawesome/css/all.min.css" rel="stylesheet" />
    <link href="http://localhost/restconnect/css/application.css" rel="stylesheet" />    
    <script src="http://localhost/restconnect/lib/jquery/dist/jquery.min.js"></script>
    <style>
        .row li {
            margin-left: -10px;
        }

        @media (max-width: 600px) {
            td, th {
                font-size: 0.8em;
            }
        }
    </style>
</head>
<body>
    <div class="banner">
        <a class="slide-menu-toggle-open no-slide-menu"
           title="More...">
            <i class="fas fa-bars"></i>
        </a>

        <div class="title-bar no-slide-menu">
            <a href="http://localhost/restconnect/">
                <img class="title-bar-icon" src="http://localhost/restconnect/images/icon.png" />
                <div style="float: left; margin: 4px 5px; line-height: 1.0">
                    <i style="color: #0092d0; font-size: 0.9em; font-weight: bold;">West Wind</i><br />
                    <i style="color: whitesmoke; font-size: 1.65em; font-weight: 600;">Web Connection</i>
                </div>
            </a>
        </div>

        <!-- top right nav menu - .hidable for options that hide on small sizes -->
        <nav class="banner-menu-top float-right">
            <a href="http://west-wind.com/webconnection/docs/" target="wc-docs" class="hidable">
                <i class="fas fa-book"></i>
                Docs
            </a>
            <a href="http://localhost/restconnect/admin/admin.aspx">
                <i class="fa fa-cogs"></i>
                Admin
            </a>            
        </nav>
    </div>


    <div id="MainView">
        <div class="container">
            <div class="page-header-text">
                <i class="fa fa-cog"></i>
                Com Server Execution Error
            </div>

            <div>
                The Com server threw an exception during the server method call:<p/>awr_data_cespiti.querydata_ammortamento c:\webconnectionprojects\restconnect\deploy\awr_data_cespiti.prg Error in line 32 Variable 'B' is not found. 12
            </div>
        </div>
    </div> <!-- end #MainView -->

    <footer>
        <a href="https://west-wind.com/" class="float-right">
            <img src="http://localhost/restconnect/images/WestwindText.png" />
        </a>
        <small class="hidable-xs">&copy; Westwind Technologies</small>
    </footer>

</body>
</html>

Can i customize this HTML ?

Gravatar is a globally recognized avatar based on your email address. re: Error management in REST service
  Rick Strahl
  Michele
  Jul 1, 2024 @ 07:55am

Make sure you are not running in Debug mode.

What you should see is something like this:

Gravatar is a globally recognized avatar based on your email address. re: Error management in REST service
  Michele
  Rick Strahl
  Jul 1, 2024 @ 11:32am

Ok, i see what you marked. Can i customize what is returned? Can i add something with "iscallbackerror" and "message" so i can make this response more similar to my Rest's responses?

Gravatar is a globally recognized avatar based on your email address. re: Error management in REST service
  Rick Strahl
  Michele
  Jul 1, 2024 @ 05:12pm

Yes you can override wwRestProcess::ErrorResponse() in your process class and return any JSON you see fit. Look at the base method and then copy into your class and customize. All default error responses go through that method.

+++ Rick ---

© 1996-2024