Path: blob/master/runtime/compiler/net/StreamExceptions.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2018, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21#ifndef STREAM_EXCEPTIONS_H22#define STREAM_EXCEPTIONS_H2324#include <string>25#include "net/MessageTypes.hpp"26#include "infra/Assert.hpp"2728namespace JITServer29{30class StreamFailure: public virtual std::exception31{32public:33StreamFailure() : _message("Generic stream failure") { }34StreamFailure(const std::string &message) : _message(message) { }35virtual const char* what() const throw() { return _message.c_str(); }36private:37std::string _message;38};3940class StreamInterrupted: public virtual std::exception41{42public:43StreamInterrupted() { }44virtual const char* what() const throw()45{46return "Compilation interrupted at JITClient's request";47}48};4950class StreamConnectionTerminate: public virtual std::exception51{52public:53StreamConnectionTerminate() { }54virtual const char* what() const throw()55{56return "Connection terminated at JITClient's request";57}58};5960class StreamClientSessionTerminate: public virtual std::exception61{62public:63StreamClientSessionTerminate(uint64_t clientId) : _clientId(clientId)64{65_message = "JITClient session " + std::to_string(_clientId) + " terminated at JITClient's request";66}67virtual const char* what() const throw()68{69return _message.c_str();70}71uint64_t getClientId() const72{73return _clientId;74}75private:76std::string _message;77uint64_t _clientId;78};7980class StreamOOO : public virtual std::exception81{82public:83virtual const char* what() const throw() { return "Messages arriving out-of-order"; }84};8586class StreamTypeMismatch: public virtual StreamFailure87{88public:89StreamTypeMismatch(const std::string &message) : StreamFailure(message) { TR_ASSERT(false, "Type mismatch: %s", message.c_str()); }90};9192class StreamMessageTypeMismatch: public virtual std::exception93{94public:95StreamMessageTypeMismatch() : _message("JITServer/JITClient message type mismatch detected") { }96StreamMessageTypeMismatch(MessageType serverType, MessageType clientType)97{98const char *expectedName = (serverType < MessageType_MAXTYPE) ? messageNames[serverType] : "";99const char *receivedName = (clientType < MessageType_MAXTYPE) ? messageNames[clientType] : "";100_message = "JITServer expected message type " + std::to_string(serverType) + " " + expectedName +101" received " + std::to_string(clientType) + " " + receivedName;102}103virtual const char* what() const throw()104{105return _message.c_str();106}107private:108std::string _message;109};110111class StreamVersionIncompatible: public virtual std::exception112{113public:114StreamVersionIncompatible() : _message("JITServer/JITClient incompatibility detected") { }115StreamVersionIncompatible(uint64_t serverVersion, uint64_t clientVersion)116{117_message = "JITServer expected version " + std::to_string(serverVersion) + " received " + std::to_string(clientVersion);118}119virtual const char* what() const throw()120{121return _message.c_str();122}123private:124std::string _message;125};126127class StreamArityMismatch: public virtual StreamFailure128{129public:130StreamArityMismatch(const std::string &message) : StreamFailure(message) { TR_ASSERT(false, "Arity mismatch: %s", message.c_str()); }131};132133class ServerCompilationFailure: public virtual std::exception134{135public:136ServerCompilationFailure() : _message("Generic JITServer compilation failure") { }137ServerCompilationFailure(const std::string &message) : _message(message) { }138virtual const char* what() const throw() { return _message.c_str(); }139private:140std::string _message;141};142}143#endif // STREAM_EXCEPTIONS_H144145146