David Symonds | 4d3336d | 2014-02-02 23:32:22 | [diff] [blame] | 1 | // Copyright 2013 Google Inc. All rights reserved. |
| 2 | // Use of this source code is governed by the Apache 2.0 |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package appengine |
| 6 | |
Sebastiaan van Stijn | a1ae214 | 2023-03-01 18:29:44 | [diff] [blame] | 7 | import "context" |
David Symonds | d1e7e22 | 2015-01-28 05:44:06 | [diff] [blame] | 8 | |
David Symonds | 4d3336d | 2014-02-02 23:32:22 | [diff] [blame] | 9 | // IsTimeoutError reports whether err is a timeout error. |
| 10 | func IsTimeoutError(err error) bool { |
David Symonds | d1e7e22 | 2015-01-28 05:44:06 | [diff] [blame] | 11 | if err == context.DeadlineExceeded { |
| 12 | return true |
| 13 | } |
David Symonds | 4d3336d | 2014-02-02 23:32:22 | [diff] [blame] | 14 | if t, ok := err.(interface { |
| 15 | IsTimeout() bool |
| 16 | }); ok { |
| 17 | return t.IsTimeout() |
| 18 | } |
| 19 | return false |
| 20 | } |