github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/http/errors.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package http 4 5 import ( 6 er "github.com/GeniusesGroup/libgo/error" 7 "github.com/GeniusesGroup/libgo/protocol" 8 ) 9 10 const domainEnglish = "HTTP" 11 const domainPersian = "HTTP" 12 13 // Declare package errors 14 var ( 15 ErrNoConnection er.Error 16 ErrPacketTooShort er.Error 17 ErrPacketTooLong er.Error 18 ErrParseMethod er.Error 19 ErrParseVersion er.Error 20 ErrParseStatusCode er.Error 21 ErrParseReasonPhrase er.Error 22 ErrParseHeaderTooLarge er.Error 23 ErrCookieBadName er.Error 24 ErrCookieBadValue er.Error 25 ErrCookieBadPath er.Error 26 ErrCookieBadDomain er.Error 27 ErrNotFound er.Error 28 ErrUnsupportedMediaType er.Error 29 ) 30 31 func init() { 32 ErrNoConnection.Init("domain/http.protocol; type=error; name=no-connection") 33 ErrNoConnection.SetDetail(protocol.LanguageEnglish, domainEnglish, 34 "No Connection", 35 "There is no connection to peer(server or client) to process request", 36 "", 37 "", 38 nil) 39 ErrNoConnection.SetDetail(protocol.LanguagePersian, domainPersian, 40 "عدم وجود ارتباط", 41 "هیچ راه ارتباطی با رایانه مقصد برای پردازش درخواست مورد نظر وجود ندارد", 42 "", 43 "", 44 nil) 45 46 ErrPacketTooShort.Init("domain/http.protocol; type=error; name=packet-too-short") 47 ErrPacketTooShort.SetDetail(protocol.LanguageEnglish, domainEnglish, 48 "Packet Too Short", 49 "Received HTTP packet size is shorter than expected and can't use", 50 "", 51 "", 52 nil) 53 54 ErrPacketTooLong.Init("domain/http.protocol; type=error; name=packet-too-long") 55 ErrPacketTooLong.SetDetail(protocol.LanguageEnglish, domainEnglish, 56 "Packet Too Long", 57 "Received HTTP packet size is larger than expected and can't use", 58 "", 59 "", 60 nil) 61 62 ErrParseMethod.Init("domain/http.protocol; type=error; name=parse-method") 63 ErrParseMethod.SetDetail(protocol.LanguageEnglish, domainEnglish, 64 "Parse Method", 65 "Parsing received HTTP packet encounter unknown situation in Method part", 66 "", 67 "", 68 nil) 69 70 ErrParseVersion.Init("domain/http.protocol; type=error; name=parse-version") 71 ErrParseVersion.SetDetail(protocol.LanguageEnglish, domainEnglish, 72 "Parse Version", 73 "Parsing received HTTP packet encounter unknown situation in Version part", 74 "", 75 "", 76 nil) 77 78 ErrParseStatusCode.Init("domain/http.protocol; type=error; name=parse-status-code") 79 ErrParseStatusCode.SetDetail(protocol.LanguageEnglish, domainEnglish, 80 "Parse Status Code", 81 "Parsing received HTTP packet encounter unknown situation in StatusCode part", 82 "", 83 "", 84 nil) 85 86 ErrParseReasonPhrase.Init("domain/http.protocol; type=error; name=parse-reason-phrase") 87 ErrParseReasonPhrase.SetDetail(protocol.LanguageEnglish, domainEnglish, 88 "Parse Reason Phrase", 89 "Parsing received HTTP packet encounter unknown situation in ReasonPhrase part", 90 "", 91 "", 92 nil) 93 94 ErrParseHeaderTooLarge.Init("domain/http.protocol; type=error; name=parse-header-too-large") 95 ErrParseHeaderTooLarge.SetDetail(protocol.LanguageEnglish, domainEnglish, 96 "Parse Header Too Large", 97 "Parsing received HTTP packet encounter situation that header part of http packet is larger than expected", 98 "", 99 "", 100 nil) 101 102 ErrCookieBadName.Init("domain/http.protocol; type=error; name=cookie-bad-name") 103 ErrCookieBadName.SetDetail(protocol.LanguageEnglish, domainEnglish, 104 "Cookie Bad Name", 105 "Cookie name include illegal charecter by related RFC", 106 "", 107 "", 108 nil) 109 110 ErrCookieBadValue.Init("domain/http.protocol; type=error; name=cookie-bad-value") 111 ErrCookieBadValue.SetDetail(protocol.LanguageEnglish, domainEnglish, 112 "Cookie Bad Value", 113 "Cookie value include illegal charecter by related RFC", 114 "", 115 "", 116 nil) 117 118 ErrCookieBadPath.Init("domain/http.protocol; type=error; name=cookie-bad-path") 119 ErrCookieBadPath.SetDetail(protocol.LanguageEnglish, domainEnglish, 120 "Cookie Bad Path", 121 "Cookie path include illegal charecter by related RFC", 122 "", 123 "", 124 nil) 125 126 ErrCookieBadDomain.Init("domain/http.protocol; type=error; name=cookie-bad-domain") 127 ErrCookieBadDomain.SetDetail(protocol.LanguageEnglish, domainEnglish, 128 "Cookie Bad Domain", 129 "Cookie domain is not valid by related RFC", 130 "", 131 "", 132 nil) 133 134 ErrNotFound.Init("domain/http.protocol; type=error; name=not-found") 135 ErrNotFound.SetDetail(protocol.LanguageEnglish, domainEnglish, 136 "Not Found", 137 "Requested HTTP URI Service is not found in this instance of app", 138 "", 139 "", 140 nil) 141 142 ErrUnsupportedMediaType.Init("domain/http.protocol; type=error; name=unsupported-media-type") 143 ErrUnsupportedMediaType.SetDetail(protocol.LanguageEnglish, domainEnglish, 144 "Unsupported Media Type", 145 "Refuse to accept the request or response because the payload format or encoding is in an unsupported format", 146 "", 147 "", 148 nil) 149 }