grpc.io/public/docs/guides/error/index.html

345 lines
10 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<title>
Error Handling &ndash; gRPC
</title>
<link rel="apple-touch-icon" href="/favicons/apple-touch-icon.png" sizes="180x180">
<link rel="icon" type="image/png" href="/favicons/android-chrome-192x192.png" sizes="192x192" >
<link rel="icon" type="image/png" href="/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/favicons/manifest.json">
<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg" color="#2DA6B0">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/favicons/mstile-150x150.png">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-60127042-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-60127042-1');
</script>
</head>
<body>
<div id="landing-content">
<div class="row">
<div class="topbannersub">
<nav class="navbar navbar-expand-md navbar-dark topnav">
<a class="navbar-brand" href="https://cjyabraham.github.io/">
<img src="https://cjyabraham.github.io/img/grpc-logo.png" width="114" height="50">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="topnav, collapse navbar-collapse" id="navbarSupportedContent" style="float:right !important">
<ul class="navbar-nav ml-auto">
<li class="nav-item ">
<a class="nav-link" href="https://cjyabraham.github.io/about/">About</a>
</li>
<li class="nav-item dropdown active">
<a class="nav-link dropdown-toggle" href="https://cjyabraham.github.io/docs/" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Docs
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="/docs">
Overview
</a>
<a class="dropdown-item" href="/docs/quickstart/">
Quick Start
</a>
<a class="dropdown-item" href="/docs/guides/">
Guides
</a>
<a class="dropdown-item" href="/docs/tutorials/">
Tutorials
</a>
<a class="dropdown-item" href="/docs/reference/">
Reference
</a>
<a class="dropdown-item" href="/docs/samples/">
Samples
</a>
<a class="dropdown-item" href="/docs/talks">
Presentations
</a>
</div>
</li>
<li class="nav-item ">
<a class="nav-link" href="/blog">
Blog
</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="/community">Community</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://packages.grpc.io/">
Packages
</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="https://cjyabraham.github.io/faq/">FAQ</a>
</li>
</ul>
</div>
</nav>
<div class="headertext">Documentation</div>
</div>
</div>
</div>
<div class="subnav d-none d-md-block">
<a href="https://cjyabraham.github.io/docs/" >Overview</a>
| <a href="https://cjyabraham.github.io/docs/quickstart/" >Quick Start</a>
| <a href="https://cjyabraham.github.io/docs/guides/" class="active">Guides</a>
| <a href="https://cjyabraham.github.io/docs/tutorials/" >Tutorials</a>
| <a href="https://cjyabraham.github.io/docs/reference/" >Reference</a>
| <a href="https://cjyabraham.github.io/docs/samples/" >Samples</a>
| <a href="https://cjyabraham.github.io/docs/talks/" >Presentations</a>
</div>
<div class="quickstartcols">
<div class="quickstartcol1">
<h8>Guides</h8>
<a href="/docs/guides/">
What is gRPC?
</a>
<a href="/docs/guides/concepts/">
gRPC Concepts
</a>
<a href="/docs/guides/auth/">
Authentication
</a>
<a href="/docs/guides/error/" class="active">
Error handling and debugging
</a>
<a href="/docs/guides/benchmarking/">
Benchmarking
</a>
<a href="https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md">
gRPC Wire Format
</a>
<h8 style="margin-top:25%">Related Guides</h8>
<a href="https://developers.google.com/protocol-buffers/docs/overview">Protocol Buffers</a>
</div>
<div class="quickstartcol2" style="margin-top:4%">
<h3 style="margin-top:0px;">
Error Handling
</h3>
<p class="lead"> This page describes how gRPC deals with errors, including gRPC's built-in error codes. Example code in different languages can be found <a href="https://github.com/avinassh/grpc-errors">here</a>.</p>
<div id="toc" class="toc mobile-toc"></div>
<h3 id="error-model">Error model</h3>
<p>As you&rsquo;ll have seen in our concepts document and examples, when a gRPC call
completes successfully the server returns an <code>OK</code> status to the client
(depending on the language the <code>OK</code> status may or may not be directly used in
your code). But what happens if the call isn&rsquo;t successful?</p>
<p>If an error occurs, gRPC returns one of its error status codes instead, with an
optional string error message that provides further details about what happened.
Error information is available to gRPC clients in all supported languages.</p>
<h3 id="error-status-codes">Error status codes</h3>
<p>Errors are raised by gRPC under various circumstances, from network failures to
unauthenticated connections, each of which is associated with a particular
status code. The following error status codes are supported in all gRPC
languages.</p>
<h4 id="general-errors">General errors</h4>
<table>
<thead>
<tr>
<th>Case</th>
<th>Status code</th>
</tr>
</thead>
<tbody>
<tr>
<td>Client application cancelled the request</td>
<td>GRPC&#95;STATUS&#95;CANCELLED</td>
</tr>
<tr>
<td>Deadline expired before server returned status</td>
<td>GRPC&#95;STATUS&#95;DEADLINE_EXCEEDED</td>
</tr>
<tr>
<td>Method not found on server</td>
<td>GRPC&#95;STATUS&#95;UNIMPLEMENTED</td>
</tr>
<tr>
<td>Server shutting down</td>
<td>GRPC&#95;STATUS&#95;UNAVAILABLE</td>
</tr>
<tr>
<td>Server threw an exception (or did something other than returning a status code to terminate the RPC)</td>
<td>GRPC&#95;STATUS&#95;UNKNOWN</td>
</tr>
</tbody>
</table>
<p><br></p>
<h4 id="network-failures">Network failures</h4>
<table>
<thead>
<tr>
<th>Case</th>
<th>Status code</th>
</tr>
</thead>
<tbody>
<tr>
<td>No data transmitted before deadline expires. Also applies to cases where some data is transmitted and no other failures are detected before the deadline expires</td>
<td>GRPC&#95;STATUS&#95;DEADLINE_EXCEEDED</td>
</tr>
<tr>
<td>Some data transmitted (for example, the request metadata has been written to the TCP connection) before the connection breaks</td>
<td>GRPC&#95;STATUS&#95;UNAVAILABLE</td>
</tr>
</tbody>
</table>
<p><br></p>
<h4 id="protocol-errors">Protocol errors</h4>
<table>
<thead>
<tr>
<th>Case</th>
<th>Status code</th>
</tr>
</thead>
<tbody>
<tr>
<td>Could not decompress but compression algorithm supported</td>
<td>GRPC&#95;STATUS&#95;INTERNAL</td>
</tr>
<tr>
<td>Compression mechanism used by client not supported by the server</td>
<td>GRPC&#95;STATUS&#95;UNIMPLEMENTED</td>
</tr>
<tr>
<td>Flow-control resource limits reached</td>
<td>GRPC&#95;STATUS&#95;RESOURCE_EXHAUSTED</td>
</tr>
<tr>
<td>Flow-control protocol violation</td>
<td>GRPC&#95;STATUS&#95;INTERNAL</td>
</tr>
<tr>
<td>Error parsing returned status</td>
<td>GRPC&#95;STATUS&#95;UNKNOWN</td>
</tr>
<tr>
<td>Unauthenticated: credentials failed to get metadata</td>
<td>GRPC&#95;STATUS&#95;UNAUTHENTICATED</td>
</tr>
<tr>
<td>Invalid host set in authority metadata</td>
<td>GRPC&#95;STATUS&#95;UNAUTHENTICATED</td>
</tr>
<tr>
<td>Error parsing response protocol buffer</td>
<td>GRPC&#95;STATUS&#95;INTERNAL</td>
</tr>
<tr>
<td>Error parsing request protocol buffer</td>
<td>GRPC&#95;STATUS&#95;INTERNAL</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>