exceptions: Convert SyntaxException and its base classes
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.cassandra.exceptions;
|
||||
|
||||
public abstract class CassandraException extends Exception implements TransportException
|
||||
{
|
||||
private final ExceptionCode code;
|
||||
|
||||
protected CassandraException(ExceptionCode code, String msg)
|
||||
{
|
||||
super(msg);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
protected CassandraException(ExceptionCode code, String msg, Throwable cause)
|
||||
{
|
||||
super(msg, cause);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ExceptionCode code()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.cassandra.exceptions;
|
||||
|
||||
public abstract class RequestValidationException extends CassandraException
|
||||
{
|
||||
protected RequestValidationException(ExceptionCode code, String msg)
|
||||
{
|
||||
super(code, msg);
|
||||
}
|
||||
|
||||
protected RequestValidationException(ExceptionCode code, String msg, Throwable e)
|
||||
{
|
||||
super(code, msg, e);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.cassandra.exceptions;
|
||||
|
||||
public class SyntaxException extends RequestValidationException
|
||||
{
|
||||
public SyntaxException(String msg)
|
||||
{
|
||||
super(ExceptionCode.SYNTAX_ERROR, msg);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EXCEPTIONS_HH
|
||||
|
||||
#include <stdexcept>
|
||||
#include "core/sstring.hh"
|
||||
|
||||
namespace exceptions {
|
||||
|
||||
@@ -49,6 +50,38 @@ enum exception_code {
|
||||
UNPREPARED = 0x2500
|
||||
};
|
||||
|
||||
class transport_exception {
|
||||
public:
|
||||
virtual exception_code code() const = 0;
|
||||
virtual sstring get_message() const = 0;
|
||||
};
|
||||
|
||||
class cassandra_exception : public std::exception, public transport_exception {
|
||||
private:
|
||||
exception_code _code;
|
||||
sstring _msg;
|
||||
public:
|
||||
cassandra_exception(exception_code code, sstring msg)
|
||||
: _code(code)
|
||||
, _msg(std::move(msg))
|
||||
{ }
|
||||
virtual const char* what() const noexcept override { return _msg.begin(); }
|
||||
virtual exception_code code() const override { return _code; }
|
||||
virtual sstring get_message() const override { return what(); }
|
||||
};
|
||||
|
||||
class request_validation_exception : public cassandra_exception {
|
||||
public:
|
||||
using cassandra_exception::cassandra_exception;
|
||||
};
|
||||
|
||||
class syntax_exception : public request_validation_exception {
|
||||
public:
|
||||
syntax_exception(sstring msg)
|
||||
: request_validation_exception(exception_code::SYNTAX_ERROR, std::move(msg))
|
||||
{ }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user