Package com.github.kevwil.aspen.exception

Examples of com.github.kevwil.aspen.exception.ServiceException


        {
            response = _rack.process( request );
            if( response == null )
            {
                response = new Response( request );
                response.setException( new ServiceException( "null response from Rack" ) );
            }
            if( !response.hasException() && response.getResponseStatus().getCode() >= 400 )
            {
                response.setException( new ServiceException( response.getResponseStatus() ) );
            }
        }
        catch( Exception ex )
        {
            assert response != null;
View Full Code Here


                                                           args,
                                                           Block.NULL_BLOCK );
            if( callResult.isNil() )
            {
                Response err = new Response( request );
                err.setException( new ServiceException( "'nil' was returned from the app" ) );
                return err;
            }
            if( callResult.getType().toString().equals( "Rack::File" ) )
            {
                RubyObject.puts( callResult.inspect() );
                // TODO: return a file-based response
                Response err = new Response( request );
                err.setException( new ServiceException( "body is a Rack::File - need to handle it differently" ) );
                return err;
            }
            try
            {
                RubyArray result = (RubyArray)callResult;
View Full Code Here

    Response createResponse( final Request request, final RubyArray result )
    {
        Response r = new Response( request );
        if( result.size() != 3 )
        {
            r.setException( new ServiceException( "bad rack response: " + result.inspect().toString() ) );
            return r;
        }
        IRubyObject body = request.getRuntime().getNil();
        try
        {
            IRubyObject result1 = result.entry( 0 );
            if( result.isNil() )
            {
                r.setException( new ServiceException( "bad rack response, null status code: " + result.inspect().toString() ) );
                return r;
            }
            int codeInt = RubyInteger.num2int( result1 );
            if( codeInt < 100 )
            {
                r.setException( new ServiceException( "bad rack response, status code integer less than 100" ) );
                return r;
            }
            r.setResponseCode( codeInt );

            RubyHash headers = result.entry( 1 ).convertToHash();
View Full Code Here

    void writeBodyToResponse( final IRubyObject body, final Response response )
    {
        if( !body.respondsTo( "each" ) )
        {
            throw new ServiceException( "response body does not respond to :each" );
        }
        ChannelBuffer bodyBuffer = RubyUtil.bodyToBuffer( body );
        response.setBody( bodyBuffer.toString( Charset.forName( "UTF-8" ) ) );
    }
View Full Code Here

    {
        _httpResponse = createMock( HttpResponse.class );
        _writer = new MockErrorResponseWriter();
        _writer.setResponse( _httpResponse );
        _httpRequest = new DefaultHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/" );
        _exception = new ServiceException( "Oops!" );
        _rack = createMock( RackProxy.class );
        ChannelHandler handler = new RackChannelUpstreamHandler( _rack );
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast( "handler", handler );
        new DefaultLocalServerChannelFactory().newChannel( pipeline );
View Full Code Here

            {
                result = new URL( sb.toString() );
            }
            catch( MalformedURLException mue )
            {
                throw new ServiceException( mue );
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of com.github.kevwil.aspen.exception.ServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.